开发者

Load workflow in 2 aspx pages

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 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(fals开发者_运维知识库e);
        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 the workflow nothing happens. Does anyone have any ideas how to approach it? Thx for your time


It looks like you'll be blocking on the first WaitOne as once loaded the workflow won;t go idle until started

Does the workflow run if you remove the first wait?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜