protected void ExecuteRequest() { ThreadMethodEntry method = null; lock (this.queue) { if (queue.Count > 0) { method = queue.Dequeue(); } } if (method != null) { try { if (method.Entry != null) { method.Entry(); } } catch (Exception ex) { InvocationException ie = new InvocationException(method.ErrorMessage, ex); Application.OnThreadException(ie); } } }
public void BeginInvoke(MethodInvoker method) { ThreadMethodEntry entry = new ThreadMethodEntry(method); queue.Enqueue(entry); NativeMethods.PostMessage(handle, NativeMethods.CN_BEGININVOKE, IntPtr.Zero, IntPtr.Zero); }
public void Invoke(MethodInvoker method, string errorMessage) { ThreadMethodEntry entry = new ThreadMethodEntry(method, errorMessage); queue.Enqueue(entry); NativeMethods.SendMessage(new HandleRef(null, handle), NativeMethods.CN_INVOKE, IntPtr.Zero, IntPtr.Zero); }