public static void StartBackgroundJob( MonitoredActivity activity, string title, string message, Action job, Handler handler) { var dialog = ProgressDialog.Show(activity, title, message, true, false); ThreadPool.QueueUserWorkItem(w => new BackgroundJob(activity, job, dialog, handler).Run()); }
public BackgroundJob(MonitoredActivity activity, Action job, ProgressDialog progressDialog, Handler handler) { _activity = activity; _progressDialog = progressDialog; _job = job; _handler = handler; activity.Destroying += (sender, e) => { CleanUp(); handler.RemoveCallbacks(CleanUp); }; activity.Stopping += (sender, e) => progressDialog.Hide(); activity.Starting += (sender, e) => progressDialog.Show(); }