///<summary> /// <para>Executes the delegate on the main thread that this object executes on.</para> /// <para>NB: Assumption is made that Objective-C controls have been created on the Main Thread.</para> ///</summary> ///<returns> /// An <see cref="T:System.IAsyncResult"></see> interface that represents the asynchronous operation started by calling this method. ///</returns> ///<param name="args">An array of type <see cref="T:System.Object"></see> to pass as arguments to the given method. This can be null if no arguments are needed. </param> ///<param name="method">A <see cref="T:System.Delegate"></see> to a method that takes parameters of the same number and type that are contained in args. </param> public IAsyncResult BeginInvoke(Delegate method, params Object[] args) { NSResponderThreadInvoker invoker = null; try { invoker = new NSResponderThreadInvoker(method, args); invoker.PerformSelectorOnThreadWithObjectWaitUntilDone(ObjectiveCRuntime.Selector("asyncInvoke:"), this.ownerThread, invoker, false); return invoker.AsyncResult; } finally { invoker.SafeRelease(); } }
/// <summary> /// Initializes a new instance of the <see cref="NSResponderAsyncResult"/> class. /// </summary> /// <param name="invoker">The invoker.</param> public NSResponderAsyncResult(NSResponderThreadInvoker invoker) { this.mre = new ManualResetEvent(false); this.Invoker = invoker; }