在 2 个 aspx 页面中加载工作流程
我正在开发一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您将在第一个 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?