/// <summary> /// Get a handle to the session manager and request the session object by id /// this is also the signal to the session manager that this NativeSessionHost is ready /// </summary> /// <param name="creatorProcessId"></param> /// <param name="sessionId"></param> private static void RegisterSession2(int creatorProcessId, int sessionId) { SetSessionManagerProcessId(creatorProcessId); INativeSessionManager sessionManager = NativeSessionManagerClientFactory.CreateChannel(); InternalSession session = sessionManager.RegisterNativeSessionHost(sessionId); ((IClientChannel)sessionManager).Close(); InternalSession = session; }
/// <summary> /// Update the ServiceHost with the last invocation time /// </summary> /// <param name="idleTime"></param> static void UpdateServiceHostWithLastInvocationTime(DateTime lastInvocationActiveTime) { try { if (InternalSession == null) { return; } if (LogServiceCalls) { DebugLog.Message("UpdateServiceHostWithLastInvocationTime, Session: " + InternalSession.Id + ", Process: " + Process.GetCurrentProcess().Id); } InternalSession.LastFreshenDT = lastInvocationActiveTime; // send last invocation time SetSessionManagerProcessId(ServiceHostProcessId); INativeSessionManager sessionManager = NativeSessionManagerClientFactory.CreateChannel(); InternalSession session = sessionManager.FreshenNativeSession(InternalSession); ((IClientChannel)sessionManager).Close(); } catch (Exception ex) { string msgToIgnore = "There was no endpoint listening at net.pipe:"; if (Lex.Contains(ex.Message, msgToIgnore)) { return; } DebugLog.Message("Session: " + InternalSession.Id + ", Process: " + Process.GetCurrentProcess().Id + ", " + DebugLog.FormatExceptionMessage(ex)); } return; }