public void GetDataNoUpdates(string subject, bool getInbox, bool getSent) { // Save info for later use _subject = subject; _getInbox = getInbox; _getSent = getSent; _emailWorkerWorkMethod = getDataNoUpdatesStart; _emailWorkerProgressMethod = getDataProgressSingleMail; _emailWorkerCompleteMethod = getDataComplete; _emailWorker.RunWorkerAsync(); }
public void Start(WorkMethod method) { Progress = Functions.Start; Success = Functions.Start; WorkingMethod = method; switch (WorkingMethod) { case WorkMethod.NoThread: OnWorking(); break; case WorkMethod.ThreadInForeground: case WorkMethod.ThreadInBackground: workingThread = new Thread(new ThreadStart(OnWorking)); switch (WorkingMethod) { case WorkMethod.ThreadInBackground: workingThread.IsBackground = true; break; } workingThread.Start(); break; } }
public void EnableConnection() { _emailWorkerWorkMethod = enableConnectionStart; _emailWorkerCompleteMethod = enableConnectionComplete; _emailWorker.RunWorkerAsync(); }
/// <summary> /// Displays a modal progress dialog form and kicks off a work method using a BackgroundWorker; the modal progress dialog form will remain in the foreground until the user presses cancel AND a checkpoint in the work code is reached, or until the work completes. /// </summary> /// <param name="actionTitle">The title of the dialog form/window</param> /// <param name="initialCurrentAction">The initial status text in the window</param> /// <param name="estimatedCount">The estimated total number of work items to be performed</param> /// <param name="workMethod">The delegate method that will actually do the work</param> /// <param name="bgWorkerArgument">The object that will get passed to the delegate</param> /// <returns></returns> public DialogResult StartProgressDialog(string actionTitle, string initialCurrentAction, long estimatedCount, WorkMethod workMethod, object bgWorkerArgument) { if (_dialogForm == null) { _dialogForm = new ProgressDialogForm(); _dialogForm.btn_Cancel.Click += new EventHandler(btn_Cancel_Click); } else { throw new Exception("This class can only display one dialog at a time, per instance of the class."); } ActionTitle = actionTitle; TotalEstimatedCount = estimatedCount; CurrentCount = 0; if (!string.IsNullOrEmpty(initialCurrentAction)) { CurrentAction = initialCurrentAction; } else { CurrentAction = ""; } StartDateTime = DateTime.Now; UpdateDisplay(); //record the work method _doBgWork += workMethod; //start the worker _bgWorker.RunWorkerAsync(bgWorkerArgument); //block the underlying UI (and code flow) by showing this modal form. return(_dialogForm.ShowDialog()); }