diff --git a/DolphinBisectTool/Backend.cs b/DolphinBisectTool/Backend.cs index 5d7dad1..a9838ef 100644 --- a/DolphinBisectTool/Backend.cs +++ b/DolphinBisectTool/Backend.cs @@ -101,6 +101,7 @@ public void Bisect(string boot_title = "") { string sb = string.Join(", ", skipped_builds.ToArray()); log.Write("Skipped builds: " + sb); + log.Dispose(); } UserInput open_url = BisectEvent(test_index, true); diff --git a/DolphinBisectTool/Logger.cs b/DolphinBisectTool/Logger.cs index 39239fe..c0c71b7 100644 --- a/DolphinBisectTool/Logger.cs +++ b/DolphinBisectTool/Logger.cs @@ -6,25 +6,34 @@ namespace DolphinBisectTool { - class Logger + class Logger : IDisposable { StreamWriter log_file; + bool disposed = false; + public Logger() { log_file = new StreamWriter("log-" + DateTime.Now.ToString("yyyy-MM-dd_hhmmss") + ".txt"); } - ~Logger() + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) { - // TODO - figure out why closing the file here throws an exception. - try + if (disposed) + return; + + if (disposing) { log_file.Close(); } - catch (Exception e) - { - } + + disposed = true; } public void Write(string s)