C# Class SIL.FieldWorks.Common.Controls.ProgressDialogWithTask

A progress dialog (with an optional cancel button) that displays while a task runs in the background.
Inheritance: IAdvInd3, IAdvInd4, IFWDisposable
Show file Open project: sillsdev/FieldWorks Class Usage Examples

Public Methods

Method Description
CheckDisposed ( ) : void

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.

This method is thread safe.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

ImportTranslatedListsForWs ( Form parentWindow, FdoCache cache, string ws ) : void

I'd like to put all this logic into XmlTranslatedLists, because it is common to most cases of calling ImportTranslatedListsForWs, which is the point of this method. Unfortunately FDO cannot reference the DLL that has ProgressDialogWithTask. I've made it public static so that anything that references FwControls can use it at least.

ProgressDialogWithTask ( Form owner ) : System

Initializes a new instance of the ProgressDialogWithTask class that will create an actual progress dialog box to track the progress.

ProgressDialogWithTask ( ISynchronizeInvoke synchronizeInvoke ) : System

Initializes a new instance of the ProgressDialogWithTask class.

RunTask ( Func backgroundTask ) : object

If progress dialog is already showing, we run the background task using it (without creating a separate thread). Otherwise we display a new progress dialog as a modal dialog and start the background task in a separate thread.

RunTask ( bool fDisplayUi, Func backgroundTask ) : object

Displays the progress dialog as a modal dialog and starts the background task.

Step ( int cSteps ) : void

Steps the specified number of steps.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

m_progressDialog_Canceling ( object sender, System.CancelEventArgs e ) : void

Calls subscribers to the cancel event.

Private Methods

Method Description
AddStartListener ( ) : void
DialogShown ( ) : void
DialogShown ( object sender, EventArgs e ) : void
ImportTranslatedListsForWs ( IThreadedProgress dlg, object args ) : object

Method with required signature for ProgressDialogWithTask.RunTask, to invoke XmlTranslatedLists.ImportTranslatedListsForWs. Should only be called by the other overload of ImportTranslatedListsForWs. args must be a writing system identifier string and an FdoCache.

InitOnOwnerThread ( ) : void
LaunchDialogAndTask ( IWin32Window owner ) : void
ProgressDialogWithTask ( Form owner, ISynchronizeInvoke synchronizeInvoke ) : System

Initializes a new instance of the ProgressDialogWithTask class.

RemoveStartListener ( ) : void
RunBackgroundTask ( object sender, DoWorkEventArgs e ) : void

Executes the background task.

This method runs in the background thread!

m_progressDialog_FormClosing ( object sender, FormClosingEventArgs e ) : void
m_worker_RunWorkerCompleted ( object sender, RunWorkerCompletedEventArgs e ) : void

Method Details

CheckDisposed() public method

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.
This method is thread safe.
public CheckDisposed ( ) : void
return void

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

ImportTranslatedListsForWs() public static method

I'd like to put all this logic into XmlTranslatedLists, because it is common to most cases of calling ImportTranslatedListsForWs, which is the point of this method. Unfortunately FDO cannot reference the DLL that has ProgressDialogWithTask. I've made it public static so that anything that references FwControls can use it at least.
public static ImportTranslatedListsForWs ( Form parentWindow, FdoCache cache, string ws ) : void
parentWindow System.Windows.Forms.Form
cache FdoCache
ws string
return void

ProgressDialogWithTask() public method

Initializes a new instance of the ProgressDialogWithTask class that will create an actual progress dialog box to track the progress.
public ProgressDialogWithTask ( Form owner ) : System
owner System.Windows.Forms.Form The form to use as the owner when creating the actual progress /// dialog.
return System

ProgressDialogWithTask() public method

Initializes a new instance of the ProgressDialogWithTask class.
public ProgressDialogWithTask ( ISynchronizeInvoke synchronizeInvoke ) : System
synchronizeInvoke ISynchronizeInvoke
return System

RunTask() public method

If progress dialog is already showing, we run the background task using it (without creating a separate thread). Otherwise we display a new progress dialog as a modal dialog and start the background task in a separate thread.
Wraps any exception thrown by the background /// task
public RunTask ( Func backgroundTask ) : object
backgroundTask Func The background task.
return object

RunTask() public method

Displays the progress dialog as a modal dialog and starts the background task.
Wraps any exception thrown by the background /// task
public RunTask ( bool fDisplayUi, Func backgroundTask ) : object
fDisplayUi bool set to true to display the progress dialog, /// false to run without UI.
backgroundTask Func The background task.
return object

Step() public method

Steps the specified number of steps.
public Step ( int cSteps ) : void
cSteps int The count of steps. If it's 0, step the default step size
return void

m_progressDialog_Canceling() protected method

Calls subscribers to the cancel event.
protected m_progressDialog_Canceling ( object sender, System.CancelEventArgs e ) : void
sender object The sender.
e System.CancelEventArgs The instance containing the event data.
return void