我有一個只允許異步調用的庫,我的代碼需要同步。下面的代碼能正確工作嗎?任何人都可以預見到它的任何問題?C#同步進行異步調用
RestResponse<T> response = null;
bool executedCallBack = false;
client.ExecuteAsync(request, (RestResponse<T> aSyncResponse)=>{
executedCallBack = true;
response = aSyncResponse;
});
while (!executedCallBack){
Thread.Sleep(100);
}
..continue execution synchronously
不,我沒有得到IAsyncResult。下面的ManualResetEvent和AutoResetEvent有什麼區別? – 2011-01-22 17:45:37