From 5442a0c9196cd9b4ec4214408bbb25802739cffc Mon Sep 17 00:00:00 2001 From: "Douglas R. Miles" Date: Thu, 10 Sep 2009 01:25:04 +0000 Subject: [PATCH] MainForm lets LogForm handles the InvokeNeeded git-svn-id: https://radegast.googlecode.com/svn/trunk@217 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast/Core/RadegastLogger.cs | 2 ++ Radegast/GUI/Dialogs/DebugLog.Designer.cs | 9 ++++++++- Radegast/GUI/Dialogs/DebugLog.cs | 13 +++++++++++-- Radegast/GUI/Dialogs/MainForm.cs | 7 ++++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Radegast/Core/RadegastLogger.cs b/Radegast/Core/RadegastLogger.cs index 46e3b5e..3328e19 100644 --- a/Radegast/Core/RadegastLogger.cs +++ b/Radegast/Core/RadegastLogger.cs @@ -85,6 +85,8 @@ namespace Radegast lock (this) { + // No need to have ArgumemntNullException in File.AppendText + if (RadegastInstance.GlobalInstance.GlobalLogFile==null) return; StreamWriter logfile = File.AppendText(RadegastInstance.GlobalInstance.GlobalLogFile); logfile.WriteLine(loggingMessage); logfile.Close(); diff --git a/Radegast/GUI/Dialogs/DebugLog.Designer.cs b/Radegast/GUI/Dialogs/DebugLog.Designer.cs index b74f625..d8e08c0 100644 --- a/Radegast/GUI/Dialogs/DebugLog.Designer.cs +++ b/Radegast/GUI/Dialogs/DebugLog.Designer.cs @@ -28,6 +28,8 @@ // // $Id$ // +using System.Windows.Forms; + namespace Radegast { partial class frmDebugLog @@ -36,7 +38,7 @@ namespace Radegast /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - + /// /// Clean up any resources being used. /// @@ -47,6 +49,11 @@ namespace Radegast { components.Dispose(); } + if (rtbLog.InvokeRequired) + { + rtbLog.BeginInvoke(new MethodInvoker(() => base.Dispose(disposing))); + } + else base.Dispose(disposing); } diff --git a/Radegast/GUI/Dialogs/DebugLog.cs b/Radegast/GUI/Dialogs/DebugLog.cs index 13a4d02..0a1b66f 100644 --- a/Radegast/GUI/Dialogs/DebugLog.cs +++ b/Radegast/GUI/Dialogs/DebugLog.cs @@ -37,6 +37,15 @@ namespace Radegast { private RadegastInstance instance; + new public void Close() + { + if (rtbLog.InvokeRequired) + { + rtbLog.BeginInvoke(new MethodInvoker(Close)); + } else + base.Close(); + } + public frmDebugLog(RadegastInstance instance) { InitializeComponent(); @@ -50,9 +59,9 @@ namespace Radegast public void AddLogMessage(string msg, log4net.Core.Level level) { - if (InvokeRequired) + if (rtbLog.InvokeRequired) { - BeginInvoke(new MethodInvoker(delegate() { AddLogMessage(msg, level); })); + rtbLog.BeginInvoke(new MethodInvoker(delegate() { AddLogMessage(msg, level); })); return; } diff --git a/Radegast/GUI/Dialogs/MainForm.cs b/Radegast/GUI/Dialogs/MainForm.cs index c4526a1..35ae526 100644 --- a/Radegast/GUI/Dialogs/MainForm.cs +++ b/Radegast/GUI/Dialogs/MainForm.cs @@ -494,9 +494,10 @@ namespace Radegast public void AddLogMessage(string msg, log4net.Core.Level level) { - if (debugLogForm != null) - { - BeginInvoke(new MethodInvoker(delegate() { debugLogForm.AddLogMessage(msg, level); })); + if (debugLogForm != null && !debugLogForm.IsDisposed) + { + // Log form handlles the InvokeNeeded + debugLogForm.AddLogMessage(msg, level); } } -- 2.11.0