Lets looks at some simple C# async/await code where I have an object reference (obj
) before and after an await
with ConfigureAwait(false)
private async Task<SomeObject> AnAsyncLibraryMethod(SomeObject obj)
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
obj.Name = "Harry"; // <-- obj here
// MAIN POINT
var newSubObj = await FetchOverHttpAsync().ConfigureAwait(false);
// Continuation here
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
obj.Name = "Sally"; // <-- same obj here
return obj;
}
public class SomeObject { public string Name; }
ConfigureAwait(false)
seems to means NOT marshal the continuation back to the original context captured - ok, but what does that really mean? I've tried the code above and obj
IS correctly referenced back (even when it resumes on a different thread).
So the "context" doesn't appear to be the thread's working memory (i.e. thread local storage). So what does "context" contain? Therefore, what does it really mean to
marshal the continuation back to the original context captured