예제 #1
0
        public CustomTransfer UpdateProcessListTransfers()
        {
            long totalDownloaded = 0;
            long totalUploaded   = 0;

            lock (PIDUsageDictionary)
            {
                lock (MainWindowForm.ProcessDataSourceLocker)
                {
                    foreach (Int32 PIDWithCurrentZeroTransferSpeed in ListOfPidTransfersToBeZeroed)
                    {
                        var processesDataToBeUpdated = ProcessDataSource.Where(processData =>
                                                                               processData.PID == PIDWithCurrentZeroTransferSpeed);
                        foreach (ProcessData processData in processesDataToBeUpdated)
                        {
                            processData.SetDownloadingTransfer(0);
                            processData.SetUploadingTransfer(0);
                        }
                    }
                    ListOfPidTransfersToBeZeroed.Clear();
                    foreach (KeyValuePair <Int32, CustomTransfer> PIDUsagePair in PIDUsageDictionary)
                    {
                        ProcessData processDataToBeUpdated = ProcessDataSource.FirstOrDefault(
                            processData => (processData.isAlive || (Utils.ElapsedTime(processData.EndTime) < DeadPIDLookupTimer)) &&
                            processData.PID == PIDUsagePair.Key);
                        if (!(processDataToBeUpdated is null))
                        {
                            processDataToBeUpdated.AddReceivedSize(PIDUsagePair.Value.Received);
                            processDataToBeUpdated.AddUploadSize(PIDUsagePair.Value.Sent);
                            processDataToBeUpdated.SetDownloadingTransfer(Utils.CalculateSpeedPerSecond(PIDUsagePair.Value.Received, stopWatch.ElapsedMilliseconds));
                            processDataToBeUpdated.SetUploadingTransfer(Utils.CalculateSpeedPerSecond(PIDUsagePair.Value.Sent, stopWatch.ElapsedMilliseconds));
                            ListOfPidTransfersToBeZeroed.Add(PIDUsagePair.Key);
                        }
예제 #2
0
        private void MarkDeadProcessesInSource(Process[] processList)
        {
            List <ProcessData> deadProcesses = new List <ProcessData>();

            foreach (ProcessData processData in ProcessDataSource.Where(processData => processData.isAlive))
            {
                Process process = processList.FirstOrDefault(_process => IsProcessEqualProcessData(_process, processData));
                if (process == null)
                {
                    processData.MarkDead();
                }
            }
        }