Example #1
0
        public void Run()
        {
            TrafficMonitorTask = new TrafficMonitor(MainWindowFormCallback, ProcessDataSource, CancellationTokenTask, ListRefreshRate);
            TrafficMonitorTask.StartMonitoringInternetTrafficAsync();

            while (!CancellationTokenTask.IsCancellationRequested)
            {
                Stopwatch startStopwatch = Stopwatch.StartNew();
                try
                {
                    List <ProcessData> newProcesses      = GetNewProcesses();
                    CustomTransfer     TotalTransferSize = TrafficMonitorTask.UpdateProcessListTransfers();

                    InvokeUpdateUI(newProcesses, TotalTransferSize);
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"Received exception on monitor thread: {e.Message}");
                    if (!(MainWindowForm.ErrorLogger is null))
                    {
                        MainWindowForm.ErrorLogger.LogObject(Utils.GetCallerClassFuncName(), 10, "Failed to refresh process list", e);
                    }
                }
                SleepDelay(startStopwatch);
            }
        }
Example #2
0
        private void InvokeUpdateUI(List <ProcessData> newProcesses, CustomTransfer totalTransferSize)
        {
            UIUpdateInvokeStatus = MainWindowFormCallback.BeginInvoke((MethodInvoker) delegate
            {
                DataGridViewWithProcessDataListSource dataGridView = MainWindowFormCallback.GetProcessGridView();

                dataGridView.SaveAndSuspendCurrentView();

                AddNewProcesses(newProcesses);
                MainWindowFormCallback.UpdateVisibilityOfDeadProcessesInDataGridView(false);
                UpdateSortedDataInDataGridView(shouldMarkDeadProcesses: true);

                dataGridView.RestoreAndResumeCurrentView();
                dataGridView.Refresh();

                UpdateBottomToolStrip(totalTransferSize);
            });
        }
Example #3
0
 private static void SafeAddNetworkData(Dictionary <int, CustomTransfer> PIDUsageDictionary, Int32 PID, Int32 Rcvd, Int64 Sent)
 {
     lock (PIDUsageDictionary)
     {
         if (PIDUsageDictionary.ContainsKey(PID))
         {
             PIDUsageDictionary[PID].Received += Rcvd;
             PIDUsageDictionary[PID].Sent     += Sent;
         }
         else
         {
             PIDUsageDictionary[PID] = new CustomTransfer
             {
                 Received = Rcvd,
                 Sent     = Sent
             };
         }
     }
 }
Example #4
0
 private void UpdateBottomToolStrip(CustomTransfer totalTransferSize)
 {
     MainWindowFormCallback.UpdateNoOfShowedProcessesInTable();
     MainWindowFormCallback.AddTotalDownloadUpload(totalTransferSize.Received, totalTransferSize.Sent);
 }