Databases Reference
In-Depth Information
Console.WriteLine(“The new cube created by AMO is
available through ADOMD.”);
//Roll back the transaction.
server.RollbackTransaction();
//Close the AMO connection;this call does not end the session.
server.Disconnect(false);
//Close the ADOMD.NET connection; this call does close
//the session.
adomdConnection.Close();
}
catch (AmoException amoException)
{
Console.WriteLine(amoException.Message);
}
catch (AdomdException adomdException)
{
Console.WriteLine(adomdException.Message);
}
}
Canceling Long-Running Operations
When you write a client application that provides a user interface, you do not want to
make your user wait, unable to continue working with the user interface, while a long-
running operation finishes. Some of the operations that AMO performs, such as the
processing of some databases, can take a long time. In addition, AMO executes all opera-
tions synchronously, which means that a call to a process method will not return a
response until AMO has received the server response. To make sure that your user does
not have to wait, we recommend that you use a different thread for executing long-
running operations so that the user can continue to use the application during the opera-
tion.
It is also a good idea to enable users to cancel an operation. AMO provides the
Server.CancelCommand method, which sends a request to the server to cancel the request.
CancelCommand works similarly to the Cancel method in ADOMD.NET. When the client
application calls Server.CancelCommand , AMO opens a new XML/A connection using the
same connection properties that were used to establish the original connection. Then,
AMO sends the <Cancel> request to the server. (It can take some time for the server to
actually cancel the request.)
In the “Asynchronous Execution and Cancellation of Commands” section in Chapter 33,
we presented a simple application that executes a query in one thread and cancels it in
another. You can use AMO to write a similar application that processes a cube in one
thread and cancels processing in another. This client application has three buttons:
Search WWH ::




Custom Search