// Resume an import from the user interface protected void ImportResumedFromUI() { // Set the import control to resume ImportControl importcontrol = new ImportControl(); importcontrol.Resume = true; // Background worked does not really have a concept of resume so we just re run the background worker. bgwImport.RunWorkerAsync(importcontrol); }
// DoWork event private void bgwImport_DoWork(object sender, DoWorkEventArgs e) { // Get the BackgroundWorker that raised this event. BackgroundWorker worker = sender as BackgroundWorker; // Get the import control ImportControl importcontrol = e.Argument as ImportControl; // Call the appropriate import method if (importcontrol.Resume) { importdocument.ImportItems(worker); } else { importdocument.LoadItems(worker); importdocument.ImportItems(worker); } }
// Start an import from the user interface protected void ImportStartedFromUI() { // Get the current import settings from the UI ImportSettings importsettings = ImportSettingsFromUI(); // Initialise the import object importdocument = new ImportDocument(importsettings); // Set the import control to start a new import ImportControl importcontrol = new ImportControl(); importcontrol.Resume = false; // Start a back ground thread that will import the documents into SharePoint whilst the user interface remains responsive. bgwImport.RunWorkerAsync(importcontrol); // Enable the pause button. buttonPauseImport.Enabled = true; }