Databases Reference
In-Depth Information
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Trace handling occurs on the thread created by AMO, not on the main thread. Therefore,
if you want to use the trace event handler to manipulate the user interface controls that
were created on the main thread, you have to marshal calls to the UI controls on the main
thread. In this example, we use the Invoke method of each UI control—tree view and
progress bar—but you can achieve the same results by different means:
// Increment the progress report bar.
//Since Trace events are called from the thread created by AMO,
//thread marshaling is required to access the UI controls.
delegate void IncrementReportDelegate();
void IncrementReport()
{
if (processProgress.InvokeRequired)
{
IncrementReportDelegate d =
new IncrementReportDelegate(IncrementReport);
this.Invoke(d);
}
else
{
processProgress.Increment(10);
}
}
//Add or update the node of the report tree.
//Because Trace events are called from the thread created by AMO,
//thread marshaling is required to access the UI controls.
delegate void AddNodeDelegate(string text, AddNodeType addNodeType,
Color color);
void AddNode(string text, AddNodeType addNodeType, Color color)
{
if (reportTree.InvokeRequired)
{
AddNodeDelegate d = new AddNodeDelegate(AddNode);
this.Invoke(d, new object[] { text, addNodeType ,color});
}
else
{
TreeNode node;
switch (addNodeType)
Search WWH ::




Custom Search