protected override void QueueTask(Task task) { // Create an item and use a lambda to call TryExecuteTask() AsynchronousRunLoopItem<object, object> item = new AsynchronousRunLoopItem<object, object>( s => { TryExecuteTask(task); return null; }, null, null); // Queue up the item at the scheduler priority and do not wait for it to execute // Any unhandled exceptions should be caught by TryExecuteTask() _runLoop.Enqueue(item, _priority); }
public override void Post(SendOrPostCallback callback, object state) { if (callback == null) throw new ArgumentNullException("callback"); // Create an item and use a lambda to convert the SendOrPostCallback to a Func<object,object> AsynchronousRunLoopItem<object, object> item = new AsynchronousRunLoopItem<object, object>(s => { callback(s); return null; }, state, callback.Method); // Queue up the item and do not wait for it to execute // Any unhandled exceptions will crash the main thread _runLoop.Enqueue(item, RunLoop.Priority.Normal); }