Ejemplo n.º 1
0
        public override async Task Close()
        {
            Trace.TraceInformation("Yams is sending an exit message to the app");
            try
            {
                UnsubscribeFromExited();

                await _ipcConnection.SendMessage("[EXIT]").Timeout(_config.GracefulShutdownMessageTimeout);

                Trace.TraceInformation("Exit message sent!");

                await _ipcConnection.Disconnect();

                if (!await ProcessUtils.SpinWaitForExit(this, (int)_config.AppGracefulShutdownTimeout.TotalSeconds))
                {
                    throw new TimeoutException($"The app {this.ExePath} did not exit in time");
                }
                Trace.TraceInformation("App has exited gracefully!");
            }
            catch (TimeoutException e)
            {
                Trace.TraceError($"App {ExePath} did not respond to exit message, attempting to close the process..{e.Message}");
                await _process.Close();

                Trace.TraceInformation("App has been closed");
            }
        }
Ejemplo n.º 2
0
 public override async Task Kill()
 {
     await Task.WhenAll(_ipcConnection.Disconnect(), base.Kill());
 }