BackgroundWorker_ProgressChanged
(
object sender,
ProgressChangedEventArgs e
)
{
AssertValid();
// Forward the event.
ProgressChangedEventHandler oGraphMetricCalculationProgressChanged =
this.GraphMetricCalculationProgressChanged;
if (oGraphMetricCalculationProgressChanged != null)
{
// There are two sources of this event: the graph metric
// calculators in the Algorithms namespace, which set e.UserState
// to a simple string ("Calculating vertex degrees," for example);
// and this GraphMetricCalculationManager class, which sets
// e.UserState to a GraphMetricProgress object. In the first case,
// wrap the simple string in a new GraphMetricProgress object.
if (e.UserState is String)
{
String sProgressMessage = (String)e.UserState;
e = new ProgressChangedEventArgs(e.ProgressPercentage,
new GraphMetricProgress(sProgressMessage, false) );
}
oGraphMetricCalculationProgressChanged(this, e);
}
}