Helper class to facilitate asynchronous workers on pre-dotnet-4.5 machines, using the native system threading model and an abstraction for synchronisation with the UI thread for user feedback on completion and exception
예제 #1
0
 public static HabaneroBackgroundWorker Run(this HabaneroBackgroundWorker self, Control uiControl,
                                            ConcurrentDictionary <string, object> data,
                                            HabaneroBackgroundWorker.BackgroundWorkerMethodDelegate backgroundWorker,
                                            HabaneroBackgroundWorker.UIWorkerMethodDelegate onSuccess,
                                            HabaneroBackgroundWorker.UIWorkerMethodDelegate onCancel,
                                            HabaneroBackgroundWorker.BackgroundWorkerExceptionHandlerDelegate onException)
 {
     return(HabaneroBackgroundWorker.Run(new ActionDispatcher(uiControl), data, backgroundWorker, onSuccess, onCancel, onException));
 }
 public static HabaneroBackgroundWorker Run(this HabaneroBackgroundWorker self, Control uiControl,
     ConcurrentDictionary<string, object> data, 
     HabaneroBackgroundWorker.BackgroundWorkerMethodDelegate backgroundWorker,
     HabaneroBackgroundWorker.UIWorkerMethodDelegate onSuccess,
     HabaneroBackgroundWorker.UIWorkerMethodDelegate onCancel,
     HabaneroBackgroundWorker.BackgroundWorkerExceptionHandlerDelegate onException)
 {
     return HabaneroBackgroundWorker.Run(new ActionDispatcher(uiControl), data, backgroundWorker, onSuccess, onCancel, onException);
 }
예제 #3
0
        /// <summary>
        /// Convenience method for creating an HabaneroBackgroundWorker.
        /// </summary>
        /// <param name="dispatcher"></param>
        /// <param name="data"></param>
        /// <param name="backgroundWorker"></param>
        /// <param name="onSuccess"></param>
        /// <param name="onCancel"></param>
        /// <param name="onException"></param>
        /// <returns></returns>
        public static HabaneroBackgroundWorker Run(IActionDispatcher dispatcher, ConcurrentDictionary <string, object> data, BackgroundWorkerMethodDelegate backgroundWorker, UIWorkerMethodDelegate onSuccess, UIWorkerMethodDelegate onCancel, BackgroundWorkerExceptionHandlerDelegate onException)
        {
            var runner = new HabaneroBackgroundWorker()
            {
                ActionDispatcher = dispatcher,
                BackgroundWorker = backgroundWorker,
                OnSuccess        = onSuccess,
                OnCancelled      = onCancel,
                OnException      = onException,
                Data             = data
            };

            runner.Run();
            return(runner);
        }
 public static HabaneroBackgroundWorker Run(IActionDispatcher dispatcher, ConcurrentDictionary<string, object> data, BackgroundWorkerMethodDelegate backgroundWorker, UIWorkerMethodDelegate onSuccess, UIWorkerMethodDelegate onCancel, BackgroundWorkerExceptionHandlerDelegate onException)
 {
     var runner = new HabaneroBackgroundWorker()
         {
             ActionDispatcher = dispatcher,
             BackgroundWorker = backgroundWorker,
             OnSuccess = onSuccess,
             OnCancelled = onCancel,
             OnException = onException,
             Data = data
         };
     runner.Run();
     return runner;
 }