1234567891011121314151617181920212223242526 |
- using System;
- using System.Windows.Threading;
-
- namespace ComeCapture.Helpers
- {
- public static class WpfHelper
- {
- public static Dispatcher MainDispatcher { get; set; }
-
- public static void SafeRun(this Action action)
- {
- if (MainDispatcher == null)
- {
- action();
- return;
- }
-
- if (!MainDispatcher.CheckAccess())
- {
- MainDispatcher.BeginInvoke(action);
- return;
- }
- action();
- }
- }
- }
|