关于“事件控制工作流”的程序问题!

lyandsmx 2009-04-23 03:15:56
我程序理解上出了个问题,希望帮忙解决一下!
这是百度知道我提出的问题 有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();
}
}
}
}
...全文
40 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
freewind0521 2009-04-24
  • 打赏
  • 举报
回复

//这里EventHellow和(null, new ExternalDataEventArgs(id))这两个参数是做什么的呢?我看网上说第一个是事件 第二个是派生 我根本不明白 希望能解释一下
EventHello(null, new ExternalDataEventArgs(id));

如果不明白什么是派生,建立先看看理论,要不然你理解起来比较难


this.SayHello(instance.InstanceId);

this代表当前对象,默认就是,可以不用

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧