예제 #1
0
        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());
        }
예제 #2
0
        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();
        }