public static HostManager RegisterHost(IHost host) { if (host == null) throw new ArgumentNullException("host"); Log.WriteInfo("Registering host of type {0}", host.GetType()); var manager = new HostManager(host); lock (_registrations) _registrations.Add(host, manager); return manager; }
public static HostManager RegisterHost(IHost host) { if (host == null) { throw new ArgumentNullException(nameof(host)); } var manager = new HostManager(host); lock (_registrations) _registrations.Add(host, manager); return(manager); }
public static void UnregisterHost(IHost host) { Log.WriteInfo("Unregistering host of type {0}", host.GetType()); HostManager managerToDispose = null; lock (_registrations) { if (_registrations.ContainsKey(host)) { managerToDispose = _registrations[host]; _registrations.Remove(host); } } managerToDispose?.Dispose(); }
public static HostManager RegisterHost(IHost host) { if (host == null) { throw new ArgumentNullException(nameof(host)); } Log.WriteInfo("Registering host of type {0}", host.GetType()); var manager = new HostManager(host); lock (_registrations) _registrations.Add(host, manager); return(manager); }
public static void UnregisterHost(IHost host) { HostManager managerToDispose = null; lock (_registrations) { if (_registrations.ContainsKey(host)) { managerToDispose = _registrations[host]; _registrations.Remove(host); } } managerToDispose?.Dispose(); }
private void TryInitializeHosting() { if (_hostManager != null) return; lock (SyncRoot) { Thread.MemoryBarrier(); if (_hostManager != null) return; var hostManager = HostManager.RegisterHost(Host); Thread.MemoryBarrier(); _hostManager = hostManager; try { Host.RaiseStart(); _hostManager.Resolver.Resolve<ILogger<OwinLogSource>>(); } catch { HostManager.UnregisterHost(Host); _hostManager = null; throw; } } }