private void tvWorkitems_Expanding(object sender, TreeViewAdvEventArgs e)
        {
            if (!IsHandleCreated)
            {
                return;
            }

            Invoke(new Action(() => waitCursor.Show()));
        }
        public void Run(Action task, Action onComplete, Action <Exception> onError = null)
        {
            worker.DoWork             += (sender, e) => task.Invoke();
            worker.RunWorkerCompleted += (sender, e) => {
                if (e.Error != null && onError != null)
                {
                    onError.Invoke(e.Error);
                }

                onComplete.Invoke();
                waitCursor.Hide();
            };

            waitCursor.Show();
            worker.RunWorkerAsync();
        }
예제 #3
0
        /// <summary>
        /// This is synchronous projection of <see cref="BackgroundTaskRunner.Run"/>
        /// </summary>
        public void Run(Action task, Action onComplete, Action <Exception> onError = null)
        {
            waitCursor.Show();

            Exception exception = null;

            try {
                task.Invoke();
            } catch (Exception ex) {
                exception = ex;
            }

            if (onError != null && exception != null)
            {
                onError.Invoke(exception);
            }

            onComplete.Invoke();
            waitCursor.Hide();
        }