locked
Load workflow in 2 aspx pages RRS feed

  • Question

  • I am working on an ASP .net project. I have 2 pages. In the first page i have the following code which creates a new workflow



      var connStr = @"Data Source=M-PC\SQLEXPRESS;Initial Catalog=sella;Integrated Security=True;Pooling=False";
        AutoResetEvent syncEvent = new AutoResetEvent(false);
        var store = new SqlWorkflowInstanceStore(connStr);
        var app = new WorkflowApplication(new Activity1() { str = 4 });
        app.InstanceStore = store;
    
        app.Idle = delegate(WorkflowApplicationIdleEventArgs o)
        {
    
          syncEvent.Set();
        };
    
        app.Unloaded = (workflowApplicationEventArgs) =>
        {
          syncEvent.Set();
        };
    
        app.Run();
        syncEvent.WaitOne();
    
        string text = TextBox3.Text;
        app.ResumeBookmark("readText", text);
        syncEvent.WaitOne();
        app.Unload();
        syncEvent.WaitOne();
        Response.Redirect("WebForm1.aspx");
    

    Then in the next page WebForm1.aspx i am trying to reload the same workflow from the instance store in order to resume another bookmark with the following code:

     var connStr = @"Data Source=M-PC\SQLEXPRESS;Initial Catalog=sella;Integrated Security=True;Pooling=False";
        AutoResetEvent syncEvent = new AutoResetEvent(false);
        var store = new SqlWorkflowInstanceStore(connStr);
        var app = new WorkflowApplication(new Activity1());
        app.InstanceStore = store;
    
        app.Idle = delegate(WorkflowApplicationIdleEventArgs o)
        {
    
          syncEvent.Set();
        };
        app.Completed = delegate(WorkflowApplicationCompletedEventArgs o)
        {
          syncEvent.Set();
        };
    
        id = new Guid(TextBox2.Text.ToString());
        app.Load(id);
        syncEvent.WaitOne();
        app.Run();
        syncEvent.WaitOne();
    
        string text = TextBox1.Text;
        app.ResumeBookmark("readText1", text);
        syncEvent.WaitOne();
    

    But when i execute this code in WebForm1.aspx nothing happens. Does anyone have any ideas to approach this problem?. Thx for your time

    Tuesday, July 12, 2011 5:53 PM

Answers

  • Hi,

    To make sure your workflow will be persisted in database ,you also need to implement PersistableIdle Action;  

                     wfApp.PersistableIdle=(e)=>{                 
                           return PersistableIdleAction.Persist;           
                     };


    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, July 21, 2011 6:52 AM
    Monday, July 18, 2011 2:59 AM