Example #1
0
        private async Task LaunchAsync(string path)
        {
            if (!String.IsNullOrEmpty(appName))
            {
                Process batProcess = new Process();
                batProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(path);
                batProcess.StartInfo.FileName         = path;
                batProcess.Start();

                Process[] processes = Process.GetProcessesByName(appName);
                while (processes.Length == 0)
                {
                    await Task.Delay(1000);

                    processes = Process.GetProcessesByName(appName);
                }

                process         = processes.First();
                process.Exited += OnProcessExited;
                process.EnableRaisingEvents = true;
            }
            else
            {
                process = new Process();
                process.StartInfo.WorkingDirectory = Path.GetDirectoryName(path);
                process.StartInfo.FileName         = path;
                process.EnableRaisingEvents        = true;
                process.Exited += OnProcessExited;
                process.Start();
            }

            logger.Info($"{process.ProcessName} started at {DateTime.Now}");

            OnApplicationStarted?.Invoke(this, process);
        }
Example #2
0
 public void StartApplication()
 {
     OnApplicationStarted?.Invoke();
 }