private static EventPipeSession CreateSessionFromResponse(IpcEndpoint endpoint, ref IpcResponse?response, string operationName) { try { DiagnosticsClient.ValidateResponseMessage(response.Value.Message, operationName); long sessionId = BitConverter.ToInt64(response.Value.Message.Payload, 0); var session = new EventPipeSession(endpoint, response.Value, sessionId); response = null; return(session); } finally { response?.Dispose(); } }
protected virtual void Dispose(bool disposing) { // If session being disposed hasn't been stopped, attempt to stop it first if (!_stopped) { try { Stop(); } catch {} // swallow any exceptions that may be thrown from Stop. } if (!_disposedValue) { if (disposing) { _response.Dispose(); } _disposedValue = true; } }