I am using the Logical CallContext to flow information back across a series of awaits. Interestingly, in my test console app, everything works fine. However, when running my unit test in the context of a VS UnitTest, the call context does not seems to flow across the awaits.
Inside of the method: SendRequestAsyncImpl the call context is being set, and when I query the logical call context from a breakpoint at the moment the method returns, the call context is set just fine.
However, after the await returns in the below line:
Message response = await SendRequestAsyncImpl(m, true).ConfigureAwait(false);
The logical call context is empty. I thought maybe the problem would be fixed by setting ConfigureAwait(true) rather than false. But that does not fix the issue.
It doesn't matter what I try to flow, even setting a simple value type inside of SendRequestAsyncImpl like:
System.Runtime.Remoting.Messaging.CallContext.LogicalSetData("flag", true);
is not retrievable after the await.
Why is this working from my console app? But not from my unit test? What's different? (I've seen some other stack overflow questions that refer to AppDomain issues. But I can't even marshal a bool across the await. The ability to marshal the data doesn't appear to be the issue here.)
await Task.Delay(100);
, does it flow then? – Hannahannahawait
points, but it won't flow out. – Hannahannah