private void MergeProcess(List <Process> next)
        {
            //Processes.RemoveAll(p => next.All(np => p.Id != np.Id));
            List <ProcessGridRowViewModel> processesToRemove = new List <ProcessGridRowViewModel>();

            foreach (var process in Processes)
            {
                if (next.All(p => p.Id != process.Id))
                {
                    processesToRemove.Add(process);
                }
            }
            List <ProcessGridRowViewModel> processesToAdd = new List <ProcessGridRowViewModel>();

            foreach (var process in next)
            {
                if (Processes.All(p => p.Id != process.Id))
                {
                    processesToAdd.Add(new ProcessGridRowViewModel(process));
                }
            }
            foreach (var process in processesToAdd)
            {
                Application.Current.Dispatcher.Invoke(() => Processes.Add(process));
            }
            foreach (var process in processesToRemove)
            {
                Application.Current.Dispatcher.Invoke(() => Processes.Remove(process));
            }
        }
예제 #2
0
        /// <summary>
        /// Get's the list of all new processes.
        /// </summary>
        /// <returns></returns>
        protected List <Process> GetNewProcesses()
        {
            var processes = (string.IsNullOrEmpty(ProcessName) ? Process.GetProcesses() : Process.GetProcessesByName(ProcessName)).ToList();

            processes = processes.Where(x => Processes.All(y => y.Id != x.Id))
                        .Where(x => !string.IsNullOrWhiteSpace(x.MainWindowTitle))
                        .ToList();

            return(processes);
        }
예제 #3
0
        private bool RunRule_ReleaseBarrier()
        {
            // Rule: R_B - Match barriers
            if (_unmatchedBarriers.Count != ProcessCount)
            {
                return(false);
            }

            // Its possible that the instruction has been removed from the pending queue before the p.IsBlocked property is set
            if (!AreAllProcessesBlocked())
            {
                return(false);
            }

            Debug.Assert(_unmatchedBarriers.Select(instr => instr.Owner.Rank).Distinct().Count() == ProcessCount
                         , "Somehow, a process got added to the unmatched barrier queue more than once.");
            Debug.Assert(Processes.All(p => p.IsBlocked), "All the processes should be blocked.");

            var waitHandle = GetWaitHandleForCurrentBarrier();

            Debug.Assert(_unmatchedBarriers.All(instr => Object.ReferenceEquals(instr.WaitHandle, waitHandle))
                         , "All unmatched barrier instructions should be using the same WaitHandle instance.");

            // Mark them as being matched and complete
            foreach (var barrInstr in _unmatchedBarriers)
            {
                _matched.Add(barrInstr);
                barrInstr.IsCompleted = true;
            }

            // Clear the instructions list
            _unmatchedBarriers.Clear();

            // Release the processes all at once using the single EventWaitHandle
            // But before releasing it, lets setup for the next barrier using a new handle since once Set, we won't ever Reset them.
            SetNextBarrierWaitHandle();
            waitHandle.Set();

            return(true);
        }
예제 #4
0
        private bool RunRule_ReleaseFinalizeBarrier()
        {
            // Rule: not specified in the paper - Match barrier for the MpiFinalize command
            if (_unmatchedFinalizeBarriers.Count != ProcessCount)
            {
                return(false);
            }

            // Its possible that the instruction has been removed from the pending queue before the p.IsBlocked property is set
            if (!AreAllProcessesBlocked())
            {
                return(false);
            }

            Debug.Assert(_unmatchedFinalizeBarriers.Select(instr => instr.Owner.Rank).Distinct().Count() == ProcessCount
                         , "Somehow, a process got added to the unmatched finalize barrier queue more than once.");
            Debug.Assert(Processes.All(p => p.IsBlocked), "All the processes should be blocked waiting for the finalize barrier to complete.");

            var waitHandle = FinalizeWaitHandle;

            Debug.Assert(_unmatchedFinalizeBarriers.All(instr => Object.ReferenceEquals(instr.WaitHandle, waitHandle))
                         , "All unmatched FinalizeBarrier instructions should be using the WaitHandle instance as the Runtim.FinalizeWaitHandle.");

            // Mark them as being matched and complete
            foreach (var barrInstr in _unmatchedFinalizeBarriers)
            {
                _matched.Add(barrInstr);
                barrInstr.IsCompleted = true;
            }

            // Clear the instructions list
            _unmatchedFinalizeBarriers.Clear();

            // Release the processes all at once using the single EventWaitHandle
            waitHandle.Set();

            return(true);
        }