C#???????????
???????????? ???????[ 2014/2/8 10:51:49 ] ???????????? ???????
????C#????????????????????????
??????????????? BeginInvoke ????? IAsyncResult ?? IsCompleted ??????????C#?????ú????ɡ??????????????????н???C#?????????????д????????????????????????????????????????
public class AsyncMain {
static void Main(string[] args) {
// The asynchronous method puts the thread id here.
int threadId;
// Create an instance of the test class.
AsyncDemo ad = new AsyncDemo();
// Create the delegate.
AsyncDelegate dlgt = new AsyncDelegate(ad.TestMethod);
// Initiate the asychronous call.
IAsyncResult ar = dlgt.BeginInvoke(3000??
out threadId?? null?? null);
// Poll while simulating work.
while(ar.IsCompleted == false) {
Thread.Sleep(10);
}
// Call EndInvoke to retrieve the results.
string ret = dlgt.EndInvoke(out threadId?? ar);
Console.WriteLine("The call executed on thread {0}??
with return value "{1}"."?? threadId?? ret);
}
}
|
????C#????????????????????????л??????
??????????????????????????????y????????????????????л????????????????? ThreadPool ???????С?
????????????????????????÷????? AsyncCallback ??д???? BeginInvoke??????????????????????????????????????磬???????????????????????У????????????????? EndInvoke??
??????????????????????????????y????????????????????л????????????????? ThreadPool ???????С?
????????????????????????÷????? AsyncCallback ??д???? BeginInvoke??????????????????????????????????????磬???????????????????????У????????????????? EndInvoke??
public class AsyncMain {
// Asynchronous method puts the thread id here.
private static int threadId;
static void Main(string[] args) {
// Create an instance of the test class.
AsyncDemo ad = new AsyncDemo();
// Create the delegate.
AsyncDelegate dlgt = new AsyncDelegate(ad.TestMethod);
// Initiate the asychronous call. Include an AsyncCallback
// delegate representing the callback method?? and the data
// needed to call EndInvoke.
IAsyncResult ar = dlgt.BeginInvoke(3000??
out threadId??
new AsyncCallback(CallbackMethod)??
dlgt );
Console.WriteLine("Press Enter to close application.");
Console.ReadLine();
}
// Callback method must have the same signature as the
// AsyncCallback delegate.
static void CallbackMethod(IAsyncResult ar) {
// Retrieve the delegate.
AsyncDelegate dlgt = (AsyncDelegate) ar.AsyncState;
// Call EndInvoke to retrieve the results.
string ret = dlgt.EndInvoke(out threadId?? ar);
Console.WriteLine("The call executed on thread {0}??
with return value "{1}"."?? threadId?? ret);
}
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????C#?е?StringC# Socket???????????????????C#?????????????????????????C#???????C#????????????Log4net??????δ????C#?????????????C#?????????????????C#???????????????C#????????????????C#7 ?е?Tuple??????C#??TypeScript - GeneratorC# ?????????細(xì)??????????C#?е???н???C#??MySQL?????????μ??Ч?????д??C#????C++??dll???C#??VS2010????е??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????