Created
January 31, 2021 05:48
-
-
Save heiswayi/464f5e7e9ba0bda06d2d982c044e5c81 to your computer and use it in GitHub Desktop.
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
public static class DispatchService | |
{ | |
public static void Invoke(Action action) | |
{ | |
Dispatcher dispatchObject = Application.Current.Dispatcher; | |
if (dispatchObject == null || dispatchObject.CheckAccess()) | |
{ | |
action(); | |
} | |
else | |
{ | |
dispatchObject.Invoke(action); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment