예제 #1
0
        private Application RecycleOrHandleNone(string name, ViableProcessFilter filter, HandlerForNoMatchingProcesses handler, FailureToLaunchHandler failureToLaunchHandler)
        {
            Process[] processes = Process.GetProcessesByName(name);

            List <Process> viableProcesses = filter(processes);

            if (viableProcesses.Count > 1)
            {
                failureToLaunchHandler("Cannot choose between two or more processes called " + name);
                return(null);
            }
            if (viableProcesses.Count < 1)
            {
                return(handler("Cannot find any processes called " + name));
            }
            return(new Application(viableProcesses[0], Timeout));
        }
예제 #2
0
        private Application RecycleOrHandleNone(string name, ViableProcessFilter filter, HandlerForNoMatchingProcesses handler, FailureToLaunchHandler failureToLaunchHandler)
        {
            Process[] processes = Process.GetProcessesByName(name);

            List<Process> viableProcesses = filter(processes);

            if (viableProcesses.Count > 1)
            {
                failureToLaunchHandler("Cannot choose between two or more processes called " + name);
                return null;
            }
            if (viableProcesses.Count < 1)
            {
                 return handler("Cannot find any processes called " + name);
            }
            return new Application(viableProcesses[0], Timeout);
        }