Databases Reference
In-Depth Information
To stop tracing, the client application calls the Stop method, which will disconnect from
the server and terminate the thread used for tracing:
this.server.SessionTrace.OnEvent -= new
TraceEventHandler(sessionTrace_OnEvent);
this.server.SessionTrace.Stopped -= new
TraceStoppedEventHandler(sessionTrace_Stopped);
this.server.SessionTrace.Stop();
Two categories of Trace objects are provided by AMO:
.
Customizable traces enable a client application to subscribe to specific trace events.
This category of traces is useful when you are creating applications for monitoring
and profiling the server. To create or modify a custom Trace , a client application can
use the Traces collection of the Server object.
.
Default traces are produced by the server during certain server operations, such as
processing. The client application does not have to create a new Trace object to get
additional information from the server during processing. AMO provides the
SessionTrace property on the Server object to enable client applications to sub-
scribe to the processing events.
In the previous section (“Canceling Long-Running Operations”), we demonstrated how
operations that have the potential to run for a long time can be run asynchronously and
how to cancel such operations. Now we want to extend that example and demonstrate
how to use the Trace object to display the progress of the processing operation.
Let's take the previous example and add tracing capabilities to it. In addition to the
Connect and Process buttons, let's add a progress bar that shows the progress of the
processing operation and a tree view that displays the events as they occur on the server
during the processing of the cube. The user interface display will look like the one in
Figure 34.11.
As in the previous example shown in Listing 34.14, we are using the button state for
synchronization. Immediately after establishing the connection with the server, we will
subscribe to the default trace events. We will display the trace events in the tree view
control, and we will show a progress bar that reports the progress of the cube processing.
LISTING 34.14
Using the Trace Object to Display User Interface Controls
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
Search WWH ::




Custom Search