public void AddWork(InvokeInUIThreadDelegate work) { if (isStarted) { throw new InvalidOperationException("MultiTaskHelper has already been started"); } workItems.Enqueue(work); }
public void Start() { isStarted = true; t.Stop(); if (workItems.Count == 0) { Dispose(); return; } InvokeInUIThreadDelegate item = workItems.Dequeue(); if (item == null) { return; } item(); t.Start(); }
/// <summary> /// Invoke a callback on a delayed timer. /// </summary> /// <param name="uiInvokeDelegate"></param> /// <param name="delayMillis"></param> public static Timer CallbackOnDelay(InvokeInUIThreadDelegate uiInvokeDelegate, int delayMillis) { return (new TimerHelper(uiInvokeDelegate)).Invoke(delayMillis); }
private TimerHelper(InvokeInUIThreadDelegate uiInvokeDelegate) { _uiInvokeDelegate = uiInvokeDelegate; }
/// <summary> /// Invoke a callback on a delayed timer. /// </summary> /// <param name="uiInvokeDelegate"></param> /// <param name="delayMillis"></param> public static Timer CallbackOnDelay(InvokeInUIThreadDelegate uiInvokeDelegate, int delayMillis) { return((new TimerHelper(uiInvokeDelegate)).Invoke(delayMillis)); }