Пример #1
0
 public void update()
 {
     period = new DataTransferPeriod(dataTransferStart, updateDataTransferStart(), bytesIn(), bytesOut());
     updateDataInstant();
     Tracker.Update(period, logHandler);
 }
        /// <summary>
        /// Update the tracker every second
        /// </summary>
        /// <param name="period"></param>
        /// <param name="logHandler"></param>
        public void updateSecond(DataTransferPeriod period, LogHandler logHandler)
        {
            if (second == 60)
            {
                second = 0;
                updateMinute(logHandler);
            }
            bytesIn -= bytesStartPerSecond.bytesIn;
            bytesOut -= bytesStartPerSecond.bytesOut;
            seconds[second].set(period.getBytesIn(), period.getBytesOut());
            bytesIn += seconds[second].bytesIn;
            bytesOut += seconds[second].bytesOut;

            // restarting seems to fix any odd numbers that are being shown
            if (bytesIn < 0 || bytesOut < 0)
            {
                /*
                String text = "Restarted from DTT at: " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + Environment.NewLine +
                                    " Bytes: In: " + bytesIn + " Out: " + bytesOut + Environment.NewLine +
                                    " Per Second: In: " + bytesStartPerSecond.bytesIn + " Out: " + bytesStartPerSecond.bytesOut + Environment.NewLine +
                                    " Leftover: In: " + bytesStartLeftover.bytesIn + " Out: " + bytesStartLeftover.bytesOut + Environment.NewLine;
                File.AppendAllText(Path.Combine("restart-log.txt"), text + Environment.NewLine);

                Program.restarting = true;
                if (!Program.restarting)
                {
                    Application.Restart();
                }
                */

                bytesIn = 0;
                bytesOut = 0;
            }

            second++;
        }