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的用法
最新推荐文章于 2025-03-11 19:15:00 发布