/// <summary> /// HandleThreadEvent /// </summary> /// <param name="e"></param> private void HandleThreadEvent(MyEventArgs e) { if (DispatcherObject.Thread != Thread.CurrentThread) { DispatcherObject.Invoke(new MyThreadEventHandler(DispatchThreadEvent), DispatcherPriority.ApplicationIdle, e); } else { DispatchThreadEvent(e); } }
/// <summary> /// ListBoxLogMessageAdd /// </summary> /// <param name="message"></param> /// <param name="color"></param> public void ListBoxLogMessageAdd(string message, System.Windows.Media.Brush color) { if (DispatcherObject.Thread != Thread.CurrentThread) { DispatcherObject.Invoke(new DMessageAdd(ListBoxLogMessageAdd), DispatcherPriority.ApplicationIdle, message, color); } else { MessageList.Add(new ListBoxLogMessageString(String.Format("{0} {1}", ++_counter, message), color, FontWeights.Normal, 14)); listBox_LogMessages.SelectedIndex = listBox_LogMessages.Items.Count - 1; listBox_LogMessages.ScrollIntoView(listBox_LogMessages.SelectedItem); if (MessageList.Count > MAX_MESSGAES) { MessageList.RemoveAt(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); }
/// <summary> /// Sets up an action to execute on the dispatcher's thread at the next opportunity. The action is not execute immediately. /// </summary> /// <param name="action">The action to execute at a later time.</param> public void BeginInvoke(System.Action action) { DebugOutput("*$*$*$ INVOKING from thread: " + NSThread.Current.Handle + ", MAIN: " + NSThread.MainThread.Handle); DispatcherObject.Invoke(this, action, false); }
/// <summary> /// Processes all messages currently queued in the message queue of the current object's <see cref="Dispatcher"/>. /// </summary> /// <param name="dispatcherObject">The current object that is associated with a <see cref="Dispatcher"/>.</param> public static void ProcessMessages(this DispatcherObject dispatcherObject) => dispatcherObject.Invoke(() => { }, DispatcherPriority.Background);