示例#1
0
        public LingvisticsProcessor()
        {
            if (!File.Exists(ProcessorFilePath))
            {
                throw (new Exception("ЕБАТЬ ВАШУ МАТЬ - '" + ProcessorFilePath + "' - НЕТ ТАКОГО ФАЙЛА"));
            }

            WindowsEvent startEvent = null;

            try
            {
                _Process = Process.Start(
                    new ProcessStartInfo()
                {
                    FileName         = ProcessorFilePath,
                    WorkingDirectory = ProcessorWorkingDirectory,
                    Arguments        = "LingvisticsServicePID=" + Process.GetCurrentProcess().Id,     //"",//string.Format("{0} {1}", _port, _uri),
                    CreateNoWindow   = true,
                    UseShellExecute  = false
                }
                    );
                var url = string.Format("ipc://LP:{0}/{1}", _Process.Id, ProcessorUri);

                //ожидание запуска и сетевой инициализации процессора
                startEvent = new WindowsEvent(string.Format("LPStartEvent_{0}", _Process.Id));
                while (!startEvent.Wait(10))
                {
                    if (_Process.HasExited)
                    {
                        throw (new ApplicationException(string.Format("Proc({0}) stopped", _Process.Id)));
                    }
                }

                _ILingvisticsProcessor = (ILingvisticsProcessor)Activator.GetObject(typeof(ILingvisticsProcessor), url);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                throw (new ApplicationException("Error on start new proc"));
            }
            finally
            {
                if (startEvent != null)
                {
                    startEvent.Close();
                }
            }
            Logger.InfoFormat("New proc({0}) start", _Process.Id);
        }
 public void Close()
 {
     _StopEvent.Set();
     _StartEvent.Close();
 }