Beispiel #1
0
        private void Log(string message)
        {
            if (TextLog.InvokeRequired)
            {
                TextLog.Invoke(new Action(() => Log(message)));
                return;
            }

            TextLog.AppendText(message + Environment.NewLine);
        }
Beispiel #2
0
        public void WriteLog(object sender, LogEventArgs e)
        {
            if (!ServerRunning)
            {
                return;
            }

            if (TextLog.InvokeRequired)
            {
                var d = new DelegateWriteLog(WriteLog);
                TextLog.Invoke(d, sender, e);
            }
            else
            {
                TextLog.SelectionStart  = TextLog.TextLength;
                TextLog.SelectionLength = 0;
                TextLog.SelectionColor  = e.Color;
                TextLog.AppendText($"{DateTime.Now}: {e.Text}{Environment.NewLine}");
                TextLog.ScrollToCaret();
            }
        }