Stop() public method

public Stop ( ) : void
return void
Ejemplo n.º 1
0
        // 命名规则: 与svc同目录下,  svc.exe 对应的批处理是 svc_Build.bat
        void RunSvcShell(ProcessModel svcModel, bool startAfterDone)
        {
            if (!svcModel.Valid)
            {
                return;
            }

            // 还在跑的进程, 必须停下来
            if (svcModel.Running)
            {
                svcModel.Stop();
            }

            var buildcmd = Path.Combine(Path.GetDirectoryName(svcModel.FileName), Path.GetFileNameWithoutExtension(svcModel.FileName) + "_Build") + ".bat";

            var shellModel = new ProcessModel();

            shellModel.FileName = buildcmd;
            shellModel.invoker  = this;
            shellModel.CanStop  = false;

            shellModel.OnStart += (m) =>
            {
                m.WriteLog(Color.Yellow, "启动Shell: " + buildcmd);
            };

            Action <ProcessModel> stopProc = (m) =>
            {
                m.WriteLog(Color.Yellow, "结束Shell: " + buildcmd);

                // 编译正常时, 启动进程
                if (startAfterDone && shellModel.ExitCode == 0)
                {
                    svcModel.Start();
                }
            };


            shellModel.OnStop += stopProc;
            shellModel.OnExit += stopProc;

            shellModel.OnLog   += svcModel.OnLog;
            shellModel.OnError += svcModel.OnError;

            shellModel.Start();

            RefreshButtonStatus();
        }
Ejemplo n.º 2
0
        // 命名规则: 与svc同目录下,  svc.exe 对应的批处理是 svc_Build.bat
        void RunSvcShell(ProcessModel svcModel, bool startAfterDone)
        {
            if (!svcModel.Valid)
                return;

            // 还在跑的进程, 必须停下来
            if (svcModel.Running)
            {
                svcModel.Stop();
            }

            var buildcmd = Path.Combine(Path.GetDirectoryName(svcModel.FileName), Path.GetFileNameWithoutExtension(svcModel.FileName) + "_Build") + ".bat";

            var shellModel = new ProcessModel();
            shellModel.FileName = buildcmd;
            shellModel.invoker = this;
            shellModel.CanStop = false;

            shellModel.OnStart += (m) =>
            {
                m.WriteLog(Color.Yellow, "启动Shell: " + buildcmd);
            };

            Action<ProcessModel> stopProc = (m) =>
            {
                m.WriteLog(Color.Yellow, "结束Shell: " + buildcmd);

                // 编译正常时, 启动进程
                if (startAfterDone && shellModel.ExitCode == 0)
                {
                    svcModel.Start();
                }
            };

            shellModel.OnStop += stopProc;
            shellModel.OnExit += stopProc;

            shellModel.OnLog += svcModel.OnLog;
            shellModel.OnError += svcModel.OnError;

            shellModel.Start();

            RefreshButtonStatus();
        }