に、私はこの種のコンテキストで使用される、待ちとWaitAsyncのSemaphoreSlim使用の違いが何であるかを見つけようとしているWaitAsync対待っ:セマフォ非同期メソッド
private SemaphoreSlim semaphore = new SemaphoreSlim(1);
public async Task<string> Get()
{
// What's the difference between using Wait and WaitAsync here?
this.semaphore.Wait(); // await this.semaphore.WaitAsync()
string result;
try {
result = this.GetStringAsync();
}
finally {
this.semaphore.Release();
}
return result;
}
他のほとんどの 'XXX'メソッドと' XXXAsync'メソッドの違いは、1つはブロックし、もう1つはスレッドを生成します。 –