private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { lock (m_lock) m_workerThread = System.Threading.Thread.CurrentThread; XervBackupRunner r = new XervBackupRunner(); //TODO: Speed up by returning the source folders from ListFiles somehow? IList<string> sourcefolders = r.ListSourceFolders(m_schedule, m_when); if (r.IsAborted || backgroundWorker.CancellationPending) { e.Cancel = true; return; } if (m_files == null || m_files.Count == 0) { IList<string> files = r.ListFiles(m_schedule, m_when); if (backgroundWorker.CancellationPending || r.IsAborted) { e.Cancel = true; return; } if (m_files != null) { m_files.Clear(); m_files.AddRange(files); } else m_files = new List<string>(files); } if (m_sourcefolders != null) { m_sourcefolders.Clear(); m_sourcefolders.AddRange(sourcefolders); } else m_sourcefolders = new List<string>(sourcefolders); if (m_targetfolders == null) m_targetfolders = new List<string>(); if (m_targetfolders.Count != m_sourcefolders.Count) { m_targetfolders.Clear(); for (int i = 0; i < m_sourcefolders.Count; i++) m_targetfolders.Add(null); } } catch (System.Threading.ThreadAbortException) { System.Threading.Thread.ResetAbort(); e.Cancel = true; } finally { lock (m_lock) m_workerThread = null; } }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { lock (m_lock) m_runner = new XervBackupRunner(); e.Result = m_runner.ListBackupEntries(m_schedule); if (m_runner.IsAborted) e.Cancel = true; } finally { lock (m_lock) m_runner = null; } }