locked
WorkflowApplication instance can be used to execute a single workflow. Why? What is the benefit? RRS feed

  • Question

  • Hi,

    WorkflowApplication instance can be used to execute a single workflow. Why? What is the benefit?

    Regards,

    Neha

    Thursday, February 3, 2011 8:38 AM

Answers

  • Hi, Neha

    In WF3/3.5. we use WorkflowRuntime to host many workflow instances.  WorkflowRuntime instance is relative slow and memory consuming. for example, if we want to host a workflow instance in ASP.NET page. we need to create a WorkflowRuntime for even one workflow instance.

    While in WF4. WorkflowApplication is a light weight workflow runtime. one WorkflowApplication for one Workflow instance. it is fast and easy to use. we can also synchronize WorkflowApplication with .net threads synchronization.

    Regards
    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Thursday, February 10, 2011 2:14 AM
    Tuesday, February 8, 2011 3:24 AM

All replies

  • Not sure I'm following the question- WorkflowApplication is the host object for a single workflow instance, and is configured with the inputs (arguments) for that instance. You're free to instanciate WorkflowApplication multiple times for multiple instances of the workflow.

    WorkflowApplication is analogous to the WorkflowInstance object from previous versions of WF; the WorkflowRuntime object (which sounds like what you're looking for) is no longer exposed in the API.

    Thursday, February 3, 2011 6:07 PM
  • One of the main differences between WorkflowApplication and WorkflowInvoker is that WorkflowInvoker.Invoke is synchronous. It won't return until the workflowcompletes. WorkflowApplication allows the host to get control back right away and thus control a workflow that might go idle and persist.

    Can you elaborate a little more on your question?

     

    Friday, February 4, 2011 12:33 AM
  • Hi, Neha

    In WF3/3.5. we use WorkflowRuntime to host many workflow instances.  WorkflowRuntime instance is relative slow and memory consuming. for example, if we want to host a workflow instance in ASP.NET page. we need to create a WorkflowRuntime for even one workflow instance.

    While in WF4. WorkflowApplication is a light weight workflow runtime. one WorkflowApplication for one Workflow instance. it is fast and easy to use. we can also synchronize WorkflowApplication with .net threads synchronization.

    Regards
    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Thursday, February 10, 2011 2:14 AM
    Tuesday, February 8, 2011 3:24 AM
  • Man, I'm having the toughest time trying to find the answer to a related question, so I'm hoping someone here will point me in the right direction quickly/easily. 

    Suppose my application shuts down while instances of my workflow haven't completed.. When my application starts back up, how do I know how many instances of WorkflowApplicaiton I need to create in order to resume all persisted workflows? Do I have to query the instance table manually? 


    I'm not a player, I just code a lot.

    Tuesday, June 12, 2012 2:52 PM
  • Have a look at http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/49dfd5a8-f937-4787-b4c2-eae1cf7e868c.

    Calling WorkflowApplication.LoadRunnableInstances in a loop should load up all the instances in the store that are runnable. Note that setting the WorkflowHostType metadata on the owner in the store is an important piece of the puzzle. If you are dealing with mulitple different workflow definitions, I believe you need to give each definition type its own WorkflowHostType so the store can differentiate when it goes looking.

    Thursday, June 14, 2012 5:51 PM
  •  benefits of WorkflowApplication

    •   To invoke the workflow asynchronously (thus improving the application responsiveness)
    •  to track down the other informations like completionstate 

    e.g. var wf = new workflow();

           var wapp = new workflowapplication(wf); // You can pass inputs also using IDicationary<string,object> collection

           wapp.run(); // to run the application asynchronously

     you can also use

    wapp.completed = e=>

    {

                e.completionstate - can be used to check the health of workflow execution

               e.outputs - to grab the output

    };

    • you can also use wapp.idle to track down the idle period of execution

    for more information you can visit the msdn link:

    http://msdn.microsoft.com/en-us/library/system.activities.workflowapplication.aspx

    Saturday, June 16, 2012 7:05 PM