Beispiel #1
0
 void WorkingProcess_Exited(object sender, EventArgs e)
 {
     m_Locker.CleanLock();
     m_PerformanceCounter = null;
     OnStopped();
 }
Beispiel #2
0
        protected override IManagedAppBase CreateAndStartServerInstance()
        {
            var currentDomain = AppDomain.CurrentDomain;

            m_Locker = new ProcessLocker(AppWorkingDir, "instance.lock");

            var process = m_Locker.GetLockedProcess();

            if (process == null)
            {
                try
                {
                    process = Process.Start(m_StartInfo);
                }
                catch (Exception e)
                {
                    OnExceptionThrown(e);
                    return null;
                }

                m_Locker.SaveLock(process);
            }

            m_WorkingProcess = process;

            process.EnableRaisingEvents = true;
            process.ErrorDataReceived += new DataReceivedEventHandler(WorkingProcess_ErrorDataReceived);
            process.BeginErrorReadLine();

            process.Exited += new EventHandler(WorkingProcess_Exited);

            m_PerformanceCounter = new ProcessPerformanceCounter(process, PerformanceCounterInfo.GetDefaultPerformanceCounterDefinitions());

            m_Status.StartedTime = DateTime.Now;
            m_Status[StatusInfoKeys.IsRunning] = true;

            return new NullManagedApp();
        }