protected override void Append(LoggingEvent loggingEvent)
{
var property = loggingEvent.LookupProperty(Config.LogKey) as string;
var form = Application.OpenForms[FormName];
TextBox textBox = null;
TabPage tabControl = null;
if(property != null)
{
tabControl = FindControl(property, form) as TabPage;
}
if (tabControl != null)
{
textBox = FindControl(TextBoxName, tabControl) as TextBox;
}
if (textBox == null)
return;
var action = new Action(() =>
{
if (textBox.Lines.Count() > 300)
textBox.Clear();
textBox.AppendText(RenderLoggingEvent(loggingEvent));
textBox.ScrollToCaret();
});
if (form.InvokeRequired)
{
form.BeginInvoke(action);
}
else
{
action();
}
}