关于“事件控制工作流”的程序问题!
我程序理解上出了个问题,希望帮忙解决一下!
这是百度知道我提出的问题 有70分
谢谢
http://zhidao.baidu.com/question/94686623.html
或者在这里回答我也非常感谢 没有什么能报答你们的 只有谢谢一句了!
我遇到一个程序问题。这个程序是教科书上的。
程序关于“事件控制工作流”的。
下面是程序代码,说白了我看不明白。希望在我提问题的地方能帮我注释一下。拜托各位了。我看懂答案后给分绝对不手软。还有追加的20分。谢谢!
注明:在设计页面的程序中已经申明了一个接口 定义了一个泛型委托
[ExternalDataExchange]
public interface IEventControl
{
event EventHandler<ExternalDataEventArgs> EventHello;
}
这个是Program.CS页面的代码
using System;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using System.Workflow.Activities;
namespace EventControlTest
{
class Program : IEventControl
{
//这句话是什么意思呢?
public event EventHandler<ExternalDataEventArgs> EventHello;
//这里我看的懂
static void Main(string[] args)
{
Program p = new Program();
p.Run();
}
//这里这个SayHellow方法是做什么的呢?(Guid id)参数是干吗的呢?
public void SayHello(Guid id)
{
//这里EventHellow和(null, new ExternalDataEventArgs(id))这两个参数是做什么的呢?我看网上说第一个是事件 第二个是派生 我根本不明白 希望能解释一下
EventHello(null, new ExternalDataEventArgs(id));
}
public void Run()
{
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false);
ExternalDataExchangeService exchangeService = new ExternalDataExchangeService();
workflowRuntime.AddService(exchangeService);
exchangeService.AddService(this);
workflowRuntime.StartRuntime();
workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(EventControlWorkflow));
instance.Start();
//这里又不明白了 this.SayHellow是做什么的呢?this为什么要使用呢?后面括号里的两个参数是做什么的呢?
this.SayHello(instance.InstanceId);
waitHandle.WaitOne();
}
}
}
}