コード例 #1
0
ファイル: UnitTest.cs プロジェクト: Oceanswave/childprocess
        public void Initialize()
        {
            VisualStudioDebugHelper.Register();

            this.manager = new CustomizedChildProcessManager();
            this.manager.ProcessStateChanged += this.ManagerOnProcessStateChanged;

            string childProcessExePath = @"..\..\..\Child\bin";

#if DEBUG
            childProcessExePath += @"\Debug\Child.exe";
#else
            childProcessExePath += @"\Release\Child.exe";
#endif

            string currentDir = Directory.GetCurrentDirectory();
            childProcessExePath = Path.Combine(currentDir, childProcessExePath);
            childProcessExePath = Path.GetFullPath(childProcessExePath);

            var processInfo  = new ProcessStartInfo(childProcessExePath);
            var childProcess = new CustomizedChildProcess();
            this.manager.StartChildProcess(processInfo, childProcess);
        }
コード例 #2
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private static void Main(string[] args)
        {
            VisualStudioDebugHelper.Register();

            var manager = new CustomizedChildProcessManager();

            manager.ProcessStateChanged += ManagerOnProcessStateChanged;

            string childProcessExePath = @"..\..\..\Child\bin";

#if DEBUG
            childProcessExePath += @"\Debug\Child.exe";
#else
            childProcessExePath += @"\Release\Child.exe";
#endif

            string currentDir = Directory.GetCurrentDirectory();
            childProcessExePath = Path.Combine(currentDir, childProcessExePath);
            childProcessExePath = Path.GetFullPath(childProcessExePath);

            var processInfo  = new ProcessStartInfo(childProcessExePath);
            var childProcess = new CustomizedChildProcess();
            manager.StartChildProcess(processInfo, childProcess);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Parent Process waiting");
            Thread.Sleep(5000);
            Console.WriteLine("Parent Process waiting");
            childProcess.ParentChildIpc.Shutdown();
            Thread.Sleep(5000);

            manager.Dispose();

            Thread.Sleep(20000);
        }