Пример #1
0
        private void StopGateway()
        {
            if (process_gateway != null)
            {
                try
                {
                    ProcessHandling.StopProcess((uint)process_gateway.Id);
                }
                catch
                { }

                process_gateway.Close();
                process_gateway.Dispose();
                process_gateway = null;
            }
        }
Пример #2
0
        private void StopAgent()
        {
            if (process_agent != null)
            {
                try
                {
                    ProcessHandling.StopProcess((uint)process_agent.Id);
                }
                catch
                { }

                process_agent.Close();
                process_agent.Dispose();
                process_agent = null;
            }
        }
Пример #3
0
        private void StartGateway()
        {
            Task.Factory.StartNew(() =>
            {
                process_gateway = new Process();

                process_gateway.StartInfo.FileName         = "java";
                process_gateway.StartInfo.Arguments        = @"-jar target/ogwapi-jar-with-dependencies.jar";
                process_gateway.StartInfo.WorkingDirectory = @"C:\VICINITY\Gateway";

                process_gateway.StartInfo.RedirectStandardOutput = true;
                process_gateway.StartInfo.RedirectStandardError  = true;

                process_gateway.StartInfo.UseShellExecute = false;
                process_gateway.StartInfo.CreateNoWindow  = true;
                process_gateway.EnableRaisingEvents       = true;

                process_gateway.OutputDataReceived += Process_Gateway_OutputDataReceived;
                process_gateway.ErrorDataReceived  += Process_Gateway_ErrorDataReceived;


                process_gateway.Start();

                try
                {
                    process_gateway.BeginErrorReadLine();
                    process_gateway.BeginOutputReadLine();
                }
                catch
                {
                    if (process_gateway != null)
                    {
                        try
                        {
                            ProcessHandling.StopProcess((uint)process_gateway.Id);
                        }
                        catch
                        { }

                        process_gateway.Close();
                        process_gateway.Dispose();
                    }
                }
            });
        }