Ejemplo n.º 1
0
        public void CanInvokeUIThreadDispatcherFromBackgroundThread()
        {
            DefaultDispatcher dispatcher = new DefaultDispatcher();
            bool calledDelegate          = false;

            BackgroundWorker backgroundThread = new BackgroundWorker();

            backgroundThread.DoWork += ((sender, e) => dispatcher.BeginInvoke(new Action <object>(o => calledDelegate = true), null));
            backgroundThread.RunWorkerAsync();

            EnqueueDelay(500);
            EnqueueCallback(() => Assert.IsTrue(calledDelegate));
            EnqueueTestComplete();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Invokes action with single argument of type T on UI thread
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="action">Action to be invoked</param>
 /// <param name="argument">Argument to pass to the invoked action</param>
 public static void BeginInvokeOnUI <T>(Action <T> action, T argument)
 => DefaultDispatcher.BeginInvoke(action, argument);