protected override void Append(LoggingEvent loggingEvent) { if (AppenderTextBox == null) { if (string.IsNullOrEmpty(FormName) || string.IsNullOrEmpty(TextBoxName)) { return; } var form = Application.OpenForms[FormName]; if (form == null) { return; } AppenderTextBox = (TextBox)FindControlRecursive(form, TextBoxName); if (AppenderTextBox == null) { return; } form.FormClosing += (s, e) => AppenderTextBox = null; } AppenderTextBox.BeginInvoke((MethodInvoker) delegate { AppenderTextBox.AppendText(RenderLoggingEvent(loggingEvent)); }); }
protected override void Append(log4net.Core.LoggingEvent loggingEvent) { if (window == null || AppenderTextBox == null) { if (string.IsNullOrEmpty(WindowName) || string.IsNullOrEmpty(TextBoxName)) return; foreach (Window window in Application.Current.Windows) { if (window.Name == WindowName) { this.window = window; } } if (window == null) return; AppenderTextBox = FindControl<TextBox>(window, TextBoxName); if (AppenderTextBox == null) return; window.Closing += (s, e) => AppenderTextBox = null; } window.Dispatcher.BeginInvoke( new Action(delegate { AppenderTextBox.AppendText(RenderLoggingEvent(loggingEvent)); })); }