none
Is it possible to pass an ActivityContext to another method RRS feed

  • Question

  • I noticed when my Execute method calls another method and pass the ActivityContext to the other method, an exception is thrown. Is there any work around to this? My activity has a not-so-straightforward logic and it would be better if I split it to different methods and each methods can set the OutArguments (and I suppose setting the OutArguments will require the context).

    Anyone faced the same problem before?

    Thursday, October 27, 2011 3:59 AM

Answers

  • Hi Louis,
    You can pass ActivityContext to another method. As Frank says, it is normally no problem.

    But, you should notice that ActivityContext is valid to use only when its corresponding Execute() method invocation is still on the stack.

    If you pass ActivityContext to another thread, or if you store it in a global so that you can access it after Execute() has returned, then you get problems.
    Tim

    Thursday, October 27, 2011 10:42 PM
    Moderator
  • Ah, now I see my problem. I am using reflection and BeginInvoke
    Tuesday, November 1, 2011 8:40 AM

All replies

  • Hi Louis,

     

    The ActivityContext can be passed to any method the same as any other reference type.  Could you post the code in question?

    Thursday, October 27, 2011 9:16 AM
  • Hi Louis,
    You can pass ActivityContext to another method. As Frank says, it is normally no problem.

    But, you should notice that ActivityContext is valid to use only when its corresponding Execute() method invocation is still on the stack.

    If you pass ActivityContext to another thread, or if you store it in a global so that you can access it after Execute() has returned, then you get problems.
    Tim

    Thursday, October 27, 2011 10:42 PM
    Moderator
  • Putting it in a different words,

    ActivityContext is valid in the scope of the execute() to which it was passed and only in that scope, when you get out of scope also the context become out of context :)

     

    Monday, October 31, 2011 5:05 PM
  • Ah, now I see my problem. I am using reflection and BeginInvoke
    Tuesday, November 1, 2011 8:40 AM