私は使用済みのC#プログラマーではないので、これがばかげている場合は申し訳ありません:-)
Windows 8用のC#アプリを開発しています。Webリクエストを実行する必要があるため、リクエストデータを処理するためのコールバックがあります。
私は標準的なアプローチを使用しています:
private static ManualResetEvent allDone = new ManualResetEvent(false);
private static void daCallback(IAsyncResult data) {
...
SampleDataSource.allDone.Set();
}
// This is the Class CONSTRUCTOR
public SampleDataSource() {
# before anything, reset allDone:
string request = "http://some.url.com";
HttpWebRequest webRequest = WebRequest.Create(request) as HttpWebRequest;
webRequest.Method = "POST";
webRequest.BeginGetResponse(new AsyncCallback(daCallback), webRequest);
Debug.WriteLine("Asked to begin get response");
SampleDataSource.allDone.WaitOne(12000);
Debug.WriteLine("Done Waiting");
#...
}
実行中、allDone(do_something内)は初期化されません。allDoneをnullと比較するための条件を追加しましたが、そうです、nullです。
「DoneWaiting」メッセージはまったく印刷されません...
私は何が間違っているのですか?
ありがとうございました