Smrf.NodeXL.ExcelTemplate.GraphMetricsAggregator.AggregateGraphMetricsAsync C# (CSharp) Method

AggregateGraphMetricsAsync() public method

public AggregateGraphMetricsAsync ( String sourceFolderPath, Microsoft workbook ) : void
sourceFolderPath String
workbook Microsoft
return void
    AggregateGraphMetricsAsync
    (
        String sourceFolderPath,
        Microsoft.Office.Interop.Excel.Workbook workbook
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sourceFolderPath) );
        Debug.Assert( Directory.Exists(sourceFolderPath) );
        Debug.Assert(workbook != null);
        AssertValid();

        if (this.IsBusy)
        {
            throw new InvalidOperationException(
                "GraphMetricsAggregator.AggregateGraphMetricsAsync: An"
                + " asynchronous operation is already in progress."
                );
        }

        // Wrap the arguments in an object that can be passed to
        // BackgroundWorker.RunWorkerAsync().

        AggregateGraphMetricsAsyncArgs oAggregateGraphMetricsAsyncArgs =
            new AggregateGraphMetricsAsyncArgs();

        oAggregateGraphMetricsAsyncArgs.SourceFolderPath = sourceFolderPath;
        oAggregateGraphMetricsAsyncArgs.Workbook = workbook;

        oAggregateGraphMetricsAsyncArgs.WorkbookSettings =
            GetWorkbookSettings(workbook);

        // Create a BackgroundWorker and handle its events.

        m_oBackgroundWorker = new BackgroundWorker();
        m_oBackgroundWorker.WorkerReportsProgress = true;
        m_oBackgroundWorker.WorkerSupportsCancellation = true;

        m_oBackgroundWorker.DoWork += new DoWorkEventHandler(
            BackgroundWorker_DoWork);

        m_oBackgroundWorker.ProgressChanged +=
            new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);

        m_oBackgroundWorker.RunWorkerCompleted +=
            new RunWorkerCompletedEventHandler(
                BackgroundWorker_RunWorkerCompleted);

        m_oBackgroundWorker.RunWorkerAsync(oAggregateGraphMetricsAsyncArgs);
    }