Created
August 1, 2018 04:01
-
-
Save sonnguyen0310/7b0f8f4bae2a0731b601a5f23d01a2d9 to your computer and use it in GitHub Desktop.
xamarin form UI thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var syncContext = SynchronizationContext.Current; // UI Thread | |
Task.Run(() => | |
{ | |
LatLon result = HeavyFunction(); // Run synchronously on background | |
syncContext.Post(state => | |
{ | |
// Run on UI Thread | |
map.Pins.Add(new Pin(…)); // Add pin or few pins | |
}, null); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment