From d8a65236cd8069ffc289f2fea24fa695b76bd239 Mon Sep 17 00:00:00 2001 From: "kenneth.skovhede@gmail.com" Date: Fri, 15 Jan 2010 23:20:33 +0000 Subject: [PATCH] Cleanup usage of a BackgroundWorker git-svn-id: https://duplicati.googlecode.com/svn/trunk@323 59da171f-624f-0410-aa54-27559c288bec --- .../GUI/HelperControls/BackupFileList.cs | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/Duplicati/GUI/HelperControls/BackupFileList.cs b/Duplicati/GUI/HelperControls/BackupFileList.cs index 67d8f7af9..8e7543c9e 100644 --- a/Duplicati/GUI/HelperControls/BackupFileList.cs +++ b/Duplicati/GUI/HelperControls/BackupFileList.cs @@ -33,7 +33,6 @@ namespace Duplicati.GUI.HelperControls { private DateTime m_when; private List m_files; - private Exception m_exception; private Schedule m_schedule; private bool m_isInCheck = false; @@ -67,39 +66,32 @@ namespace Duplicati.GUI.HelperControls private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { - try + DuplicatiRunner r = new DuplicatiRunner(); + IList files = r.ListFiles (m_schedule, m_when); + if (backgroundWorker.CancellationPending) { - m_exception = null; - DuplicatiRunner r = new DuplicatiRunner(); - IList files = r.ListFiles (m_schedule, m_when); - if (backgroundWorker.CancellationPending) - { - e.Cancel = true; - return; - } - if (m_files != null) - { - m_files.Clear(); - m_files.AddRange(files); - } - else - m_files = new List(files); + e.Cancel = true; + return; } - catch (Exception ex) + + if (m_files != null) { - m_exception = ex; + m_files.Clear(); + m_files.AddRange(files); } + else + m_files = new List(files); } private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { treeView.Nodes.Clear(); - if (m_exception != null) + if (e != null && e.Error != null) { LoadingIndicator.Visible = true; treeView.Visible = false; progressBar.Visible = false; - LoadingIndicator.Text = m_exception.Message; + LoadingIndicator.Text = e.Error.Message; return; }