Pass activity progress to caller RRS feed

  • Question

  • Hi,

    I have code activity MyActivity.cs. I create a workflow/XAML which contains MyActivity. My caller application load and executes this XAML. From inside MyActivity.cs, at execution time, I would like to pass progress information back to caller app. This information can just be an integer on basis of which caller app can show a progress bar describing how much activity has been executed. 

    What is the best way to achieve this in terms of WF? I can do some hacks to pass this information but is there any WF standard way to achieve this?


    Friday, August 27, 2010 11:22 AM


All replies

  • Hi Haris,

    One of the better ways could be to use extensions. You only have to code a class design to raise the update and to add an instance to Extension collection of you invoker (WorkfloApplication, wotkflowInvoker or workflowServiceHost).

    A class like this could be a good choise :

    public class Updater
      public void Update(Int32 value)
        // update your interface

    Add the extension like this :

    WorkflowInvoker wi = new WorkflowInvoker(new Workflow1());
    wi.Extensions.Add(new Updater());

    and use this code in your activity :

    protected override void Execute(CodeActivityContext context)
      Updater u = context.GetExtension<Updater>();
      if (u != null)
    Jérémy Jeanson MCP, MCTS http://blogs.codes-sources.com/JeremyJeanson/ (French or English spoken)
    Friday, August 27, 2010 12:21 PM

    Thanks for reply and it works fine.

    I would like to have your opinion about how should I implement this in my scenario which is a bit complicated. In my scenario I only provide the ActivityLibrary which will contain "MyActivity". Now my activity library can have many users and each of them will write his/her own caller app. Question is where should I declare my Updater class in that case? or will this solution be feasible in that scenario?

    I can do something like declaring a public event in my activity library. Caller app will register that event and activity will raise that event.. something like this can work. But I want some standard WF solution if there is any.

    Friday, August 27, 2010 2:52 PM
  • Re,

    yes it's possible you'll find all you'r looking for in this post :


    It explain with samble how an activity can add extension itselft ;)

    Jérémy Jeanson MCP, MCTS http://blogs.codes-sources.com/JeremyJeanson/ (French or English spoken)
    • Proposed as answer by JeremyJeansonMVP Friday, August 27, 2010 2:57 PM
    • Marked as answer by haris hasan Friday, August 27, 2010 3:09 PM
    Friday, August 27, 2010 2:57 PM
  • I also just recently did an newer post on same subject which has much better sample code, and follows an example somewhat closer to what you want to do in the progress bar scenario.

    Friday, March 4, 2011 1:57 AM