Example #1
0
        void _listener_Message(object sender, TraceEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new listenerMessageDelegate(_listener_Message), sender, e);
            }
            else
            {
                ListViewItem item = new ListViewItem();
                item.ImageIndex = (e.Level == TraceLevel.Error) ? 3 : (e.Level == TraceLevel.Warning) ? 2 : (e.Level == TraceLevel.Info) ? 1 : 0;
                item.Text = DateTime.Now.ToString();
                item.SubItems.Add(e.Message);
                listView1.Items.Add(item);

                listView1.EnsureVisible(listView1.Items.Count - 1);
            }
        }
Example #2
0
        static void Program_Message(object sender, TraceEventArgs e)
        {
            string text;

            if (e.Level >= TraceLevel.Info)
            {
                text = e.Message;
            }
            else
            {
                text = e.Level.ToString().ToUpper() + " : " + e.Message;
            }

            Console.WriteLine(text);

            if (_logFileWriter != null && _logFileWriter.BaseStream.CanWrite)
            {
                _logFileWriter.WriteLine(text);
            }
        }