Skip to content

Instantly share code, notes, and snippets.

@fekberg
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fekberg/5bd933ed531e14aacde5 to your computer and use it in GitHub Desktop.
Save fekberg/5bd933ed531e14aacde5 to your computer and use it in GitHub Desktop.
U NO DEADLOCK?!
/* Android - DOES NOT DEADLOCK */
Task.Run(() =>{
Thread.Sleep(2000);
RunOnUiThread(() => { });
}).Wait();
/* iOS - DEADLOCKS */
Task.Run(() =>{
Thread.Sleep(2000);
InvokeOnMainThread(() => { });
}).Wait();
/* WPF - DEADLOCKS */
Task.Run(() =>{
Thread.Sleep(2000);
Dispatcher.Invoke(() => { });
}).Wait();
/* Android - DEADLOCKS */
var syncContext = SynchronizationContext.Current;
Task.Run(() => {
syncContext.Send((x) => {
}, null);
}).Wait();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment