The Problem SolverWIndows Workflow Foundation
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename

Search

History

4-11-2008 09:44:1623-10-2008 13:14:2323-10-2008 12:14:2611-8-2008 21:09:4129-1-2008 14:13:03

List all versions

Call External Method Activity
.
Summary

A local service is a class that implements a local service interface (an interface that is decorated with ExternalDataExchangeAttribute) and is added to the ExternalDataExchangeService.

You can use the workflow communication activity command-line utility, wca.exe, to generate interface specific subclasses.

<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
        Console.WriteLine(state.theData)
        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)
        MyBase.New(instanceId)
        _reply = reply
    End Sub

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