Smrf.NodeXL.ExcelTemplate.GraphMLFilesImporter.ImportGraphMLFilesAsync C# (CSharp) Method

ImportGraphMLFilesAsync() public method

public ImportGraphMLFilesAsync ( String sourceFolderPath, String destinationFolderPath ) : void
sourceFolderPath String
destinationFolderPath String
return void
    ImportGraphMLFilesAsync
    (
        String sourceFolderPath,
        String destinationFolderPath
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sourceFolderPath) );
        Debug.Assert( Directory.Exists(sourceFolderPath) );
        Debug.Assert( !String.IsNullOrEmpty(destinationFolderPath) );
        Debug.Assert( Directory.Exists(destinationFolderPath) );
        AssertValid();

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

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

        ImportGraphMLFilesAsyncArgs oImportGraphMLFilesAsyncArgs =
            new ImportGraphMLFilesAsyncArgs();

        oImportGraphMLFilesAsyncArgs.SourceFolderPath = sourceFolderPath;

        oImportGraphMLFilesAsyncArgs.DestinationFolderPath =
            destinationFolderPath;

        // 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(oImportGraphMLFilesAsyncArgs);
    }