Databases Reference
In-Depth Information
backgroundWorker = sender as BackgroundWorker;
Cube cube = (Cube)doWorkArgs.Argument;
//Start processing.
cube.Process(ProcessType.ProcessFull);
//If the user clicks the Cancel button during processing,
// set the flag backgroundWorker.CancellationPending to true.
if(backgroundWorker.CancellationPending)
doWorkArgs.Cancel = true;
else
doWorkArgs.Result = true;
}
//This function is called by the class BackgroundWorker on the main
//thread when the function running in the background completes.
void OnCompleted(object sender, RunWorkerCompletedEventArgs completedArgs)
{
//If there was an error, notify the user.
if(completedArgs.Error != null)
{
MessageBox.Show(completedArgs.Error.Message,
completedArgs.Error.Source);
}
else if (completedArgs.Canceled)
{
MessageBox.Show(“ Processing has been canceled by the user.”);
}
else
{
//The processing completed successfully.
MessageBox.Show(“ Processing has been completed.”);
}
//Execution of the command has completed, close the connection
//and reset all buttons.
if (null != this.server && this.server.Connected)
{
this.server.Disconnect();
}
this.server = null;
connectionButton.Enabled = true;
cancelButton.Enabled = false;
processButton.Enabled = false;
}
}
}
Search WWH ::




Custom Search