示例#1
0
        public static void InvokeAsync(System.Windows.Forms.Control dispatcherObject, Action action, AsyncInvokeMode mode = AsyncInvokeMode.AsyncOnly)
        {
            if (dispatcherObject == null || dispatcherObject.IsDisposed)
            {
                return;
            }

            if (mode == AsyncInvokeMode.AllowSyncInvoke && !dispatcherObject.InvokeRequired)
            {
                action.Invoke();
            }
            else
            {
                dispatcherObject.BeginInvoke(action);
            }
        }
示例#2
0
        public static void InvokeAsync(WindowContainer container, Action action, DispatcherPriority priority = DispatcherPriority.Normal, AsyncInvokeMode mode = AsyncInvokeMode.AsyncOnly)
        {
            if (container == null || !container.IsInitialized)
            {
                return;
            }

            if (container.Window != null)
            {
                InvokeAsync(container.Window, action, priority, mode);
            }
            else
            {
                InvokeAsync(container.Form, action, mode);
            }
        }
示例#3
0
        public static void InvokeAsync(DispatcherObject dispatcherObject, Action action, DispatcherPriority priority = DispatcherPriority.Normal, AsyncInvokeMode mode = AsyncInvokeMode.AsyncOnly)
        {
            if (dispatcherObject == null || dispatcherObject.Dispatcher == null)
            {
                return;
            }

            if (mode == AsyncInvokeMode.AllowSyncInvoke && dispatcherObject.Dispatcher.CheckAccess())
            {
                action.Invoke();
            }
            else
            {
                dispatcherObject.Dispatcher.BeginInvoke(action, priority);
            }
        }
 public static void InvokeAsync(WindowContainer container, Action action, DispatcherPriority priority = DispatcherPriority.Normal, AsyncInvokeMode mode = AsyncInvokeMode.AsyncOnly)
 {
     if (container != null)
     {
         InvokeAsync(container.Window, action, priority, mode);
     }
 }