The Problem SolverWIndows Workflow Foundation
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename



27-1-2008 17:44:4027-1-2008 17:44:0527-1-2008 17:43:1127-1-2008 17:43:0227-1-2008 17:42:51

List all versions

External Data Exchange

Used to let an Activity communicate with services provided through the WorkflowRuntime.

If a ExternalDataExchange interface is used in a parallel way it needs to be decorate using the CorrelationParameterAttribute and the functions using the CorrelationInitializerCorrelationParameterAttribute and the CorrelationAliasCorrelationParameterAttribute.

They will ensure that each event is routed to the proper activity.

<ExternalDataExchange()> _
Public Interface IDemoDataExchange
    Sub SendSomeData(ByVal theData As String)
    Event ReceiveSomeData(ByVal sender As Object, ByVal e As ReceiveSomeDataEventArgs)
End Interface

Public Class DemoDataExchange
    Implements IDemoDataExchange

    Public Event ReceiveSomeData(ByVal sender As Object, ByVal e As ReceiveSomeDataEventArgs) Implements IDemoDataExchange.ReceiveSomeData

    Public Sub SendSomeData(ByVal theData As String) Implements IDemoDataExchange.SendSomeData
        Dim state As New SendSomeDataState(WorkflowEnvironment.WorkflowInstanceId, theData)
        ThreadPool.QueueUserWorkItem(AddressOf InternalSendSomeData, state)
    End Sub

    Private Sub InternalSendSomeData(ByVal stateObj As Object)
        Dim state As SendSomeDataState = stateObj
        Dim reply As String = Console.ReadLine()

        Dim args As New ReceiveSomeDataEventArgs(state.instanceId, reply)
        RaiseEvent ReceiveSomeData(Nothing, args)
    End Sub

    Private Class SendSomeDataState
        Public instanceId As Guid
        Public theData As String

        Public Sub New(ByVal instanceId As Guid, ByVal theData As String)
            Me.instanceId = instanceId
            Me.theData = theData
        End Sub
    End Class
End Class

<Serializable()> _
Public Class ReceiveSomeDataEventArgs
    Inherits ExternalDataEventArgs

    Public Sub New(ByVal instanceId As Guid, ByVal reply As String)
        _reply = reply
    End Sub

    Private _reply As String
    Public ReadOnly Property Reply() As String
            Return _reply
        End Get
    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