protected void BackgroundWorker_ProgressChanged
(object sender, ProgressChangedEventArgs e)
{
ProgressChangedEventHandler oCalculationProgressChanged =this.CalculationProgressChanged;
if (oCalculationProgressChanged != 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)
{
ProgressState oProgressMessage = new ProgressState(e.ProgressPercentage, (string)e.UserState, false);
e = new ProgressChangedEventArgs(e.ProgressPercentage, oProgressMessage);
}
oCalculationProgressChanged(this, e); //forward event
}
}