.NET 4.5 で async/await パターンを使用して、WCF でいくつかのサービス メソッドを実装しています。サービス例:
契約:
[ServiceContract(Namespace = "http://async.test/")]
public interface IAsyncTest
{
Task DoSomethingAsync();
}
実装:
MyAsyncService : IAsyncTest
{
public async Task DoSomethingAsync()
{
var context = OperationContext.Current; // context is present
await Task.Delay(10);
context = OperationContext.Current; // context is null
}
}
私が抱えている問題は、最初await OperationContext.Currentに戻った後null、にアクセスできないことですOperationContext.Current.IncomingMessageHeaders。
この単純な例では、await. しかし、実際のケースOperationContext.Currentではコール スタックの奥深くからアクセスされており、コンテキストをさらに渡すためだけに多くのコードを変更したくありません。
await手動でスタックに渡すことなく、ポイントの後に操作コンテキストを取得する方法はありますか?