locked
how to pause and resume a workflow using unload and load and also use multiple bookmarks along with them RRS feed

  • Question

  • i know that there is an article for the same but even in that article there is no use of unload although load is used my problem is that i am trying to pause a workflow several times and also using bookmarks with them so it might be creating problem

    here is a code snippet of mine i know it is wrong but what can i do make it right?

                                   

     WorkflowApplication app = new WorkflowApplication(new TripApprovalActivity());
                SqlWorkflowInstanceStore instanceStore = SetupSqlpersistenceStore();
                app.InstanceStore = instanceStore;
                app.Idle = delegate
                {
                    syncEvent.Set();
                };
                app.PersistableIdle = delegate (WorkflowApplicationIdleEventArgs e)
                {
                    return PersistableIdleAction.Unload;
                };
                app.Completed = delegate
                {
                    syncEvent.Set();
                };
                app.Unloaded = (e) =>
                {
                    //Console.ReadKey();
                    Console.WriteLine("application is unloaded");

                    syncEvent.Set();
                };
                // start the application
                app.Run();
                Console.WriteLine("abhay");
                app.ResumeBookmark("getEmployee", emp);
                //////////////*****************************put while loop here///////////********************8

                //  Console.WriteLine("enre");
                syncEvent.WaitOne();
                app.Unload();
                // app.ResumeBookmark("getEmployee", emp);
                Console.WriteLine("abhay");

               // syncEvent.WaitOne();
                return app.Id;

    thanks in advance


    • Edited by Abhay Garg Tuesday, May 23, 2017 12:28 PM
    Monday, May 22, 2017 3:09 PM

All replies

  • Hi Abhay Garg,

    please refer example below.

    Pausing a Workflow:

    try  
    {  
        // attempt to unload will fail if the workflow is idle within a NoPersistZone  
        application.Unload(TimeSpan.FromSeconds(5));  
    }  
    catch (TimeoutException e)  
    {  
        Console.WriteLine(e.Message);  
    }  

    Resuming a Workflow

    WorkflowApplication application = new WorkflowApplication(activity);  
    application.InstanceStore = instanceStore;  
    application.Load(id);  

    Reference:

    Pausing and Resuming a Workflow

    Pausing and Resuming a Workflow

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, August 17, 2017 6:00 AM