locked
AsyncCodeActivity And Variables RRS feed

  • Question

  • When writing AsyncCodeActivities, I usually store the delegate used to async invoke a method in context.UserState so I can call EndInvoke on it within EndExecute. Is it possible w/ AsyncCodeActivities just like NativeActivies to declare not just In and Out arguments for my activity but variables as well?

    If so, is there something that prevents me from store the delegate in a Variable as opposed to context.UserState/
    Blades Don't Need Reloading...
    Friday, January 22, 2010 7:11 PM

Answers

  • I believe you can only add variables to NativeActivity. If that is right, you should probably go with something like this:

    class MyAsyncCodeCodeActivity : AsyncCodeActivity
    {
        class ImportantData {
             TheDelegate { get; set; }
             StuffIWantToPutInAVariable { get; set; }
        }
        
        override BeginExecute(.....)
        {
              context.UserData = new ImportantData { TheDelegate = ...,  StuffIWantToPutInAVariable = };
        }
       
    }

    Tim

    Friday, January 22, 2010 9:21 PM

All replies

  • I believe you can only add variables to NativeActivity. If that is right, you should probably go with something like this:

    class MyAsyncCodeCodeActivity : AsyncCodeActivity
    {
        class ImportantData {
             TheDelegate { get; set; }
             StuffIWantToPutInAVariable { get; set; }
        }
        
        override BeginExecute(.....)
        {
              context.UserData = new ImportantData { TheDelegate = ...,  StuffIWantToPutInAVariable = };
        }
       
    }

    Tim

    Friday, January 22, 2010 9:21 PM
  • That's actually what I'm doing now. I'd simply like the ability though to add variables to any custom activity. It just seems cleaner to me...
    Blades Don't Need Reloading...
    Friday, January 22, 2010 9:37 PM