![]() ![]() | ||||
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename
History |
Public Class Activity1
Inherits Activity
Implements IEventActivity, IActivityEventListener(Of QueueEventArgs)
Public Sub OnEvent(ByVal sender As Object, ByVal e As QueueEventArgs) Implements IActivityEventListener(Of QueueEventArgs).OnEvent
Dim executionContext As ActivityExecutionContext = CType(sender, ActivityExecutionContext)
Dim wqs As WorkflowQueuingService = executionContext.GetService(Of WorkflowQueuingService)()
Dim queue As WorkflowQueue = wqs.GetWorkflowQueue(QueueName)
Dim item As Object = queue.Dequeue()
' ToDo: Implement
executionContext.CloseActivity()
End Sub
Protected Overrides Function Execute(ByVal executionContext As ActivityExecutionContext) As ActivityExecutionStatus
Dim status As ActivityExecutionStatus
If IsInEventActivityMode Then
status = ActivityExecutionStatus.Closed
Else
InternalSubscribe(executionContext, Me, False)
status = ActivityExecutionStatus.Executing
End If
Return status
End Function
Public ReadOnly Property QueueName() As IComparable Implements IEventActivity.QueueName
Get
Return "MyQueueName"
End Get
End Property
Public Sub Subscribe(ByVal parentContext As ActivityExecutionContext, ByVal parentEventHandler As IActivityEventListener(Of QueueEventArgs)) Implements IEventActivity.Subscribe
InternalSubscribe(parentContext, parentEventHandler, True)
End Sub
Public Sub Unsubscribe(ByVal parentContext As ActivityExecutionContext, ByVal parentEventHandler As IActivityEventListener(Of QueueEventArgs)) Implements IEventActivity.Unsubscribe
' If we are in the IsInEventActivityMode mode we need to UnregisterForQueueItemAvailable here.
End Sub
Private Sub InternalSubscribe(ByVal executionContext As ActivityExecutionContext, ByVal eventHandler As IActivityEventListener(Of QueueEventArgs), ByVal eventActivityMode As Boolean)
Dim wqs As WorkflowQueuingService = executionContext.GetService(Of WorkflowQueuingService)()
Dim queue As WorkflowQueue = wqs.CreateWorkflowQueue(QueueName, True)
queue.RegisterForQueueItemAvailable(eventHandler, QualifiedName)
IsInEventActivityMode = eventActivityMode
End Sub
Public Shared IsInEventActivityModeProperty As DependencyProperty = DependencyProperty.Register("IsInEventActivityMode", GetType(Boolean), GetType(Activity1))
<Description("This is the description which appears in the Property Browser")> _
<Category("This is the category which will be displayed in the Property Browser")> _
<Browsable(True)> _
<DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Public Property IsInEventActivityMode() As Boolean
Get
Return (CType((MyBase.GetValue(Activity1.IsInEventActivityModeProperty)), Boolean))
End Get
Set(ByVal Value As Boolean)
MyBase.SetValue(Activity1.IsInEventActivityModeProperty, Value)
End Set
End Property
End Class
| Wiki Usage
This wiki site is supposed to be a shared resource. As a shared resource everyone is encouraged to add new content or modify existing content! Enjoy the WF wiki. Recent Topics
| ||