I am using async/await pattern in .NET 4.5 to implement some service methods in WCF. Example service:
Contract:
[ServiceContract(Namespace = \"http:/
It is unfortunate that this doesn't work and we will see about getting a fix out in a future release.
In the mean time, there is a way to reapply the context to the current thread so that you don't have to pass the object around:
public async Task Add(double n1, double n2)
{
OperationContext ctx = OperationContext.Current;
await Task.Delay(100);
using (new OperationContextScope(ctx))
{
DoSomethingElse();
}
return n1 + n2;
}
In the above example, the DoSomethingElse() method will have access to OperationContext.Current as expected.