Many of you seen code like this:

public async Task Func()
{
    await SomeFuncAsync().ConfigureAwait(true);
    SomeOtherFunc();
}

Let’s assume that this code is executing in main application thread. Is it possible that SomeOtherFunc will be executed not in main application thread? Answer is yes. Let me explain why.

Here is really really simplified version of what compiler will do with our function:

public Task Func()
{
    Task task = SomeFuncAsync();
    SynchronizationContext context = SynchronizationContext.Current;
    task.ContinueWith(finishedTask => context.Post(state => { SomeOtherFunc(); }, null));
    task.Start();
    return task;
}

It actually looks completely different but from point of SynchronizationContext it looks close enough.

In short, when task will finish, it will execute provided callback in