在 2 个 aspx 页面中加载工作流程

发布于 2024-11-19 19:39:23 字数 1882 浏览 3 评论 0原文

我正在开发一个 ASP .net 项目。我有 2 页。在第一页中,我有以下代码创建一个新的工作流程

           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");

然后在下一页 WebForm1 中,我尝试从实例存储中重新加载相同的工作流程,以便使用以下代码恢复另一个书签。

          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();

但是当我执行工作流程时什么也没有发生。有谁知道如何处理它?谢谢您的时间

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(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 the workflow nothing happens. Does anyone have any ideas how to approach it? Thx for your time

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐籹人 2024-11-26 19:39:23

看起来您将在第一个 WaitOne 上阻塞,因为一旦加载工作流程将不会空闲,直到启动

如果删除第一个等待,工作流程是否会运行?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文