コード例 #1
0
        private void Start()
        {
            _startInfo.Arguments = checkBoxWatch.Checked ? "watch run" : "run --no-build";

            _process = Process.Start(_startInfo);

            _watcher.EnableRaisingEvents = !checkBoxWatch.Checked;

            richTextBoxOutput.Text = "";
            buttonStartStop.Text   = "Stop";
            checkBoxWatch.Enabled  = false;
            Running = true;

            Task.Run(() => ReadOutput());
            Task.Run(() => ReadError());
            Task.Run(() => WatchProcess());

            RunningStateChanged?.Invoke(this, EventArgs.Empty);
        }
コード例 #2
0
        private void Stop(string message)
        {
            if (!_process.HasExited)
            {
                var startInfo = new ProcessStartInfo("taskkill", $"/pid {_process.Id} /f /t")
                {
                    CreateNoWindow  = true,
                    UseShellExecute = false
                };
                Process.Start(startInfo);
            }
            _process.WaitForExit();
            Running = false;
            _watcher.EnableRaisingEvents = false;
            _process              = null;
            buttonStartStop.Text  = "Start";
            checkBoxWatch.Enabled = true;

            AppendLine("");
            AppendLine("");
            AppendLine("Server stopped: " + message);

            RunningStateChanged?.Invoke(this, EventArgs.Empty);
        }