diff --git a/src/IME WL Converter Win/Forms/MainForm.cs b/src/IME WL Converter Win/Forms/MainForm.cs index 3e0dd651..f047d649 100644 --- a/src/IME WL Converter Win/Forms/MainForm.cs +++ b/src/IME WL Converter Win/Forms/MainForm.cs @@ -519,7 +519,16 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { if (!streamExport) { - fileContent = mainBody.Convert(files); + try + { + fileContent = mainBody.Convert(files); + } + catch(Exception ex) + { + mainBody.Dispose(); + this.richTextBox1.AppendText(ex.Message); + throw ex; + } } } else diff --git a/src/ImeWlConverterCore/MainBody.cs b/src/ImeWlConverterCore/MainBody.cs index 476ee79e..a5140237 100644 --- a/src/ImeWlConverterCore/MainBody.cs +++ b/src/ImeWlConverterCore/MainBody.cs @@ -14,7 +14,7 @@ namespace Studyzy.IMEWLConverter { public delegate void ProcessNotice(string message); - public class MainBody + public class MainBody:IDisposable { public event ProcessNotice ProcessNotice; private WordLibraryList allWlList = new WordLibraryList(); @@ -429,5 +429,10 @@ private WordLibraryList ConvertChinese(WordLibraryList wordLibraryList) } return wordLibraryList; } + + public void Dispose() + { + this.timer.Stop(); + } } }