Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public class AsyncClass
public event Action SomeEventHandler;
public async Task DoAsync()
var context = SynchronizationContext.Current;
await HeavyWorkAsync().ConfigureAwait(false);
await SomeAsync().ConfigureAwait(false);
context.Post((state) =>
private Task<int> SomeAsync()
return Task.FromResult(0);
private static Task HeavyWorkAsync()
return Task.Delay(TimeSpan.FromSeconds(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment