private void Log(string message)
 {
     BeginInvoke((MethodInvoker) delegate
     {
         DateTime now = DateTime.Now;
         LogTB.AppendText($"[{now.ToShortDateString()} {now.ToLongTimeString()}] " + message + Environment.NewLine);
     });
 }
Exemple #2
0
        private void UpdateTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                int      messageCount         = 0;
                int      totalItemUpdateCount = 0;
                DateTime firstMessageTime     = DateTime.MinValue;
                DateTime lastMessageTime      = DateTime.MinValue;
                int      minItemUpdateCount   = 0;
                int      maxItemUpdateCount   = 0;

                m_tester.GetStatistics(
                    out messageCount,
                    out totalItemUpdateCount,
                    out firstMessageTime,
                    out lastMessageTime,
                    out minItemUpdateCount,
                    out maxItemUpdateCount);

                string[] messages = m_tester.GetMessages();

                for (int ii = 0; ii < messages.Length; ii++)
                {
                    LogTB.AppendText(messages[ii]);
                    LogTB.AppendText(Environment.NewLine);
                }

                MessageCountTB.Text         = String.Format("{0}", messageCount);
                TotalItemUpdateCountTB.Text = String.Format("{0}", totalItemUpdateCount);
                TimeSpan delta = (lastMessageTime - firstMessageTime);

                if (delta.TotalMilliseconds > 0)
                {
                    LogTB.AppendText(Utils.Format("Checking Update Counts. Time={0}, Min={1}, Max={2}", DateTime.UtcNow.ToString("mm:ss.fff"), minItemUpdateCount, maxItemUpdateCount));
                    LogTB.AppendText(Environment.NewLine);

                    MessageRateTB.Text         = String.Format("{0}", delta.TotalSeconds);
                    TotalItemUpdateRateTB.Text = String.Format("{0}", ((double)totalItemUpdateCount) / delta.TotalSeconds);
                }
                else
                {
                    MessageRateTB.Text         = String.Empty;
                    TotalItemUpdateRateTB.Text = String.Empty;
                }
            }
            catch (Exception)
            {
                // TBD
            }
        }
Exemple #3
0
 private void addLog(string log)
 {
     LogTB.AppendText($"{DateTime.Now:T}: {log}");
     LogTB.AppendText(Environment.NewLine);
     LogTB.ScrollToEnd();
 }