Exemplo n.º 1
0
 internal void UnregisterFromProcessMonitor()
 {
     lock (_syncLock)
     {
         if (_processMonitor != null && Process != null)
         {
             // if we've registered our process with the monitor, unregister
             _processMonitor.UnregisterChildProcess(Process);
             _processMonitor = null;
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Ensures that our process is registered with <see cref="IHostProcessMonitor"/>.
        /// </summary>
        /// <remarks>
        /// The goal is to ensure that all worker processes are registered with the monitor for the active host.
        /// There are a few different cases to consider:
        /// - Starting up in normal mode, we register on when the process is started.
        /// - When a placeholder mode host is specialized, a new host will be started but the previously initialized
        ///   worker process will remain running. We need to re-register with the new host.
        /// - When the worker process dies and a new instance of this class is created.
        /// </remarks>
        internal void RegisterWithProcessMonitor()
        {
            var processMonitor = _serviceProvider.GetScriptHostServiceOrNull <IHostProcessMonitor>();

            lock (_syncLock)
            {
                if (processMonitor != null && processMonitor != _processMonitor && Process != null)
                {
                    processMonitor.RegisterChildProcess(Process);
                    _processMonitor = processMonitor;
                }
            }
        }