Passing Variables Inside AsyncCodeActivity RRS feed

  • Question

  • I have an AsyncCodeActivity.  When BeginExecute fires, I would like to pass a variable to the delegate that I am calling.  When I do, I get the following compilation error: "...does not have a signature compatable with delegate...."  I think that means the signature of the delegate and the function don't match.  I have been unable to find any good examples in VB.Net or C# on how to do this.  Does anyone have any idea how to set the delegate up with an input parameter?  Here is my code:


      Protected Overrides Function BeginExecute(ByVal context As AsyncCodeActivityContext, ByVal callback As AsyncCallback, ByVal state As Object) As IAsyncResult
        Dim GetRandomDelegate As New Func(Of Boolean)(AddressOf CallDatabaseGetData)
        context.UserState = GetRandomDelegate
        Return GetRandomDelegate.BeginInvoke(state, callback)
      End Function
      Protected Overrides Sub EndExecute(ByVal context As AsyncCodeActivityContext, ByVal result As IAsyncResult)
        Dim GetRandomDelegate As Func(Of Boolean) = DirectCast(context.UserState, Func(Of Boolean))
      End Sub
      Private Function CallDatabaseGetData(ByVal strSomeVariable As String) As Boolean
        ' Do Something
        ' NOTE: This signature works without the input variables -> Private Function CallDatabaseGetData() As Boolean
      End Function






    • Edited by CLEAR-RCIC Wednesday, January 26, 2011 8:02 PM Formatting
    Wednesday, January 26, 2011 7:58 PM

All replies

  • which line gives you the error?
    Thursday, January 27, 2011 3:09 AM
  • The error happens on: Dim GetRandomDelegate As New Func(Of Boolean)(AddressOf CallDatabaseGetData)

    The whole error says: Private Function CallDatabaseGetData(strDatabaseInstructions As String) As Boolean' does not have a signature compatible with delegate 'Delegate Function Func(Of Boolean)() As Boolean

    Thursday, January 27, 2011 12:20 PM