Databases Reference
In-Depth Information
//When the connection is opened it is possible to start
//processing, but still impossible to cancel the process.
connectionButton.Enabled = false;
processButton.Enabled = true;
}
//This function is called when the user clicks the Process button.
private void processButton_Click(object sender, EventArgs e)
{
//Get a database object and cube object.
database = this.server.Databases.GetByName(“FoodMart 2008”);
Cube cube = database.Cubes.GetByName(“Warehouse and Sales”);
//Before starting the worker thread, disable the Process button so
//the user won't be able to click it again.
//Enable the Cancel button.
cancelButton.Enabled = true;
processButton.Enabled = false;
//Start the worker thread, then pass the Cube object as a parameter
// to the function that will be called on the worker thread.
this.backgroundWorker.RunWorkerAsync(cube);
}
//This function is called when the user clicks the Cancel button.
private void CancelButton_Click(object sender, EventArgs e)
{
//Call the Cancel method to send a cancel request to the server.
try
{
this.server.CancelCommand(this.server.SessionID);
}
catch (OperationException ex)
{
//If you send the Cancel command twice Analysis Services
//might return an error, that command is already cancelled.
//We assume that Cancel command can't through other exceptions.
}
//Inform BackgroundWorker that the request has been canceled.
this.backgroundWorker.CancelAsync();
}
//This function is called on the background thread.
void OnDoWork(object sender, DoWorkEventArgs doWorkArgs)
{
//Retrieve the Cube object from the doWorkArgs parameter.
BackgroundWorker backgroundWorker;
Search WWH ::




Custom Search