Exemplo n.º 1
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="ProcessLauncher"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (m_disposed)
            {
                return;
            }

            try
            {
                if (disposing)
                {
                    if (ForceKillOnDispose)
                    {
                        try
                        {
                            m_process.Kill();
                            m_childProcessManager?.Dispose();
                        }
                        catch (Exception ex)
                        {
                            OnProcessException(MessageLevel.Warning, new InvalidOperationException($"Exception encountered while attempting to stop process launched from \"{FileName}\": {ex.Message}", ex));
                        }
                    }

                    m_process.Dispose();
                    m_process.OutputDataReceived -= ProcessOutputDataReceived;
                    m_process.ErrorDataReceived  -= ProcessErrorDataReceived;

                    m_processUtilizationCalculator.Dispose();
                }
            }
            finally
            {
                m_disposed = true;          // Prevent duplicate dispose.
                base.Dispose(disposing);    // Call base class Dispose().
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Invoked when the debug host is unloading. By default this shuts down the remote service client.
 /// </summary>
 protected virtual void DebugHostUnloading()
 {
     // Close remote console session
     m_processManager?.Dispose();
 }