Ejemplo n.º 1
0
        /// <summary>
        /// 思考エンジンに接続する。
        /// </summary>
        public void Connect(ProcessNegotiatorData engineData)
        {
            Disconnect();

            lock (lockObject)
            {
                if (engineData == null)
                {
                    throw new ArgumentNullException("engineData");
                }

                var info = new ProcessStartInfo
                {
                    FileName               = engineData.ExeFilePath,
                    WorkingDirectory       = engineData.ExeWorkingDirectory,
                    Arguments              = engineData.ExeArguments,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = false,
                };

                var process = new System.Diagnostics.Process
                {
                    StartInfo = info,
                };

                // 子プロセスがいないとき、ここで例外が発生する。
                process.Start();

                // EXE用のprocess
                exeProcess = process;

                // remote service
                remoteService = new RemoteService(
                    process.StandardOutput.BaseStream, // read stream
                    process.StandardInput.BaseStream   // write stream
                    );

                IsLowPriority = engineData.IsLowPriority;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 思考エンジンに接続する。
        /// </summary>
        public void Connect(ProcessNegotiatorData engineData)
        {
            Disconnect();

            lock (lockObject)
            {
                if (engineData == null)
                {
                    throw new ArgumentNullException("engineData");
                }

                var info = new ProcessStartInfo
                {
                    FileName               = engineData.ExeFilePath,
                    WorkingDirectory       = engineData.ExeWorkingDirectory,
                    Arguments              = engineData.ExeArguments,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = false,
                    StandardOutputEncoding = Encode,
                };

                var process = new System.Diagnostics.Process
                {
                    StartInfo = info,
                };

                // 子プロセスがいないとき、ここで例外が発生する。
                process.Start();

                // 非同期での受信開始
                writeStream = process.StandardInput.BaseStream;
                process.OutputDataReceived += DataReceived;
                process.BeginOutputReadLine();

                // EXE用のprocess
                exeProcess = process;

                IsLowPriority = engineData.IsLowPriority;
            }
        }