示例#1
0
 /// <summary>
 /// Synchronously invokes the action on the dispatcher.
 /// </summary>
 /// <param name="action">The action to execute.</param>
 /// <param name="priority">The importance of the action to execute.</param>
 public void Invoke(System.Action action, OSDispatcherPriority priority)
 {
     if (NativeDispatcher.ManagedThreadId == MainThreadId)
     {
         // We're the main thread dispatcher -- but if not called from main thread dispatcher,
         // we need to properly direct the call.
         if (IsMainThread)
         {
             action.Invoke();
         }
         else
         {
             // Oy... Application.Invoke is *NOT* synchronous -- names are important! So,
             // adopt the mechanism from here: https://stackoverflow.com/questions/2213243/synchronous-blocking-application-invoke-for-gtk
             var wait = new ManualResetEventSlim();
             Gtk.Application.Invoke((s, e) =>
             {
                 action();
                 wait.Set();
             });
             wait.Wait();
         }
     }
     else
     {
         action.Invoke();
     }
 }
示例#2
0
 /// <summary>
 /// Synchronously invokes an action on the dispatcher with a given priority.
 /// </summary>
 /// <param name="action">The action to execute.</param>
 /// <param name="priority">The priority of the action to execute.</param>
 public void Invoke(System.Action action, OSDispatcherPriority priority)
 {
     if (NativeDispatcher != null)
     {
         NativeDispatcher.Invoke(action, (System.Windows.Threading.DispatcherPriority)priority);
     }
 }
示例#3
0
 /// <summary>
 /// Invokes a function on the main (UI) thread.
 /// </summary>
 /// <typeparam name="T">The data type of the given function's return value.</typeparam>
 /// <param name="function">A function to execute.</param>
 /// <param name="priority">The priority at which to execute <paramref name="function"/> on the main thread.</param>
 /// <returns>The return value of the function.</returns>
 public T InvokeOnMainThread <T>(System.Func <T> function, OSDispatcherPriority priority)
 {
     throw new System.NotImplementedException("InvokeOnMainThread<T>(Func<T> function, OSDispatcherPriority priority)");
 }
示例#4
0
 /// <summary>
 /// Invokes a function on the main (UI) thread.
 /// </summary>
 /// <param name="action">The action to execute.</param>
 /// <param name="priority">The priority at which to execute <paramref name="action"/> on the main thread.</param>
 public void InvokeOnMainThread(System.Action action, OSDispatcherPriority priority)
 {
     throw new System.NotImplementedException("InvokeOnMainThread(System.Action action, OSDispatcherPriority priority)");
 }
示例#5
0
 /// <summary>
 /// Synchronously invokes the action on the dispatcher.
 /// </summary>
 /// <param name="action">The action to execute.</param>
 /// <param name="priority">The importance of the action to execute.</param>
 public void Invoke(System.Action action, OSDispatcherPriority priority)
 {
     DispatcherObject.Invoke(this, action, true);
 }