Delegate异步调用总结
前几天看到这方面的一些文章,感觉有些价值,现将这些总结一下
public class DelegateClass
{
private int param;
public delegate string DemoDelegate(int param);
public DemoDelegate DemoDelegateInstance;
Delegate
Delegate异步调用 没有返回结果
Delegate异步调用 有返回结果,采用轮讯的方法
Delegate异步调用 有返回结果,采用回调的方法
}
public class App
{
[STAThread]
static void Main(string[] args)
{
DelegateClass s = new DelegateClass();
s.DemoDelegateInstance = new DelegateClass.DemoDelegate(TrueMethod);
s.SetDelegate(100);
Console.ReadLine();
}
puclic string TrueMethod(int param)
{
Console.Out.WriteLine("接受参数\t" + param.ToString());
}
}
