public void Setup()
		{
			_dialog = new ProgressDialog();
			_dialog.Text = "Unit Test";
			_dialog.Overview = "Pretending to do some work...";
			_countForWork = 0;
		}
		/// <summary>
		///
		/// </summary>
		/// <returns>false if not successful or cancelled</returns>
		private bool DoTransformWithProgressDialog(bool failureWouldBeFatal)
		{
			using (ProgressDialog dlg = new ProgressDialog())
			{
				dlg.Overview =string.Format("{0}", _taskMessage);
				BackgroundWorker worker = new BackgroundWorker();
				worker.DoWork += OnDoTransformWork;
				dlg.BackgroundWorker = worker;
				dlg.CanCancel = true;
				//dlg.CancelRequested += new EventHandler(OnCancelRequested);
				dlg.ShowDialog();
				if (dlg.ProgressStateResult!=null && dlg.ProgressStateResult.ExceptionThatWasEncountered != null)
				{
					if(failureWouldBeFatal)
						ErrorReport.ReportFatalException(dlg.ProgressStateResult.ExceptionThatWasEncountered);
				   else
					{
						ErrorReport.ReportNonFatalException(dlg.ProgressStateResult.ExceptionThatWasEncountered);
					}
					return false;
				}
				return !dlg.ProgressState.Cancel;
			}
		}
        internal void HandleBloomBookOrder(string order)
        {
            _downloadRequest = order;
            using (var progressDialog = new ProgressDialog())
            {
                _progressDialog = new ProgressDialogWrapper(progressDialog);
                progressDialog.CanCancel = false; // one day we may allow this...
                progressDialog.Overview = LocalizationManager.GetString("Download.DownloadingDialogTitle", "Downloading book");
                progressDialog.ProgressRangeMaximum = 14; // a somewhat minimal file count. We will fine-tune it when we know.
                if (IsUrlOrder(order))
                {
                    var link = new BloomLinkArgs(order);
                    progressDialog.StatusText = link.Title;
                }
                else
                {
                    progressDialog.StatusText = Path.GetFileNameWithoutExtension(order);
                }

                // We must do the download in a background thread, even though the whole process is doing nothing else,
                // so we can invoke stuff on the main thread to (e.g.) update the progress bar.
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += OnDoDownload;
                progressDialog.BackgroundWorker = worker;
                //dlg.CancelRequested += new EventHandler(OnCancelRequested);
                progressDialog.ShowDialog(); // hidden automatically when task completes
                if (progressDialog.ProgressStateResult != null &&
                    progressDialog.ProgressStateResult.ExceptionThatWasEncountered != null)
                {
                    SIL.Reporting.ErrorReport.ReportFatalException(
                        progressDialog.ProgressStateResult.ExceptionThatWasEncountered);
                }
            }
        }
		private long MeasureProgressUpdateCost(bool doMakeProgressCalls, int iterationsToDo)
		{
			_dialog = new ProgressDialog();
			BackgroundWorker worker = new BackgroundWorker();
			worker.DoWork += OnDoSomeWork;
			_dialog.BackgroundWorker = worker;
			WorkArguments args = new WorkArguments();
			args.doMakeProgressCalls = doMakeProgressCalls;
			args.secondsToUseUp = 0;
			args.iterationsToDo = iterationsToDo;
			_dialog.ProgressState.Arguments = args;
			Stopwatch w = new Stopwatch();
			w.Start();
			_dialog.ShowDialog();
			_dialog.Close();
			_dialog.Dispose();
			_dialog = null;
			w.Stop();
			worker.Dispose();
			Debug.WriteLine("Took "+ w.Elapsed);
			return w.ElapsedMilliseconds;
		}
 public ProgressDialogWrapper(ProgressDialog dialog)
 {
     _dialog = dialog;
 }