using System;
using System.Threading;
class MyTest
{
delegate bool deleTest(string a,string b);
static void Main(string[] args)
{
deleTest mytest = new deleTest(Test);
IAsyncResult testRecult = mytest.BeginInvoke("a", "b", null, null);
Write();
Console.WriteLine(mytest.EndInvoke(testRecult));
}
public static bool Test(string s1, string s2)
{
Thread.Sleep(3000);
Console.WriteLine("InTest");
if (s1 == s2)
return true;
return false;
}
public static void Write()
{
Console.WriteLine("InWrite");
}
}
/*
运行结果:
InWrite
InTest
False
*/
BeginInvoke的用法
最新推荐文章于 2023-04-11 15:37:53 发布