/// <summary>We need to get the DHCPConfig as soon as possible so that we /// can allocate static addresses, this method helps us do that.</summary> protected override void GetDhcpConfig() { if (Interlocked.Exchange(ref _lock, 1) == 1) { return; } WaitCallback wcb = delegate(object o) { bool success = false; DHCPConfig dhcp_config = null; try { dhcp_config = DhtDhcpServer.GetDhcpConfig(AppNode.Dht, _ipop_config.IpopNamespace); success = true; } catch (Exception e) { ProtocolLog.WriteIf(IpopLog.DhcpLog, e.ToString()); } if (success) { lock (_sync) { _dhcp_config = dhcp_config; _dhcp_server = new DhtDhcpServer(AppNode.Dht, _dhcp_config, _ipop_config.EnableMulticast); } } base.GetDhcpConfig(); Interlocked.Exchange(ref _lock, 0); }; ThreadPool.QueueUserWorkItem(wcb); }
/// <summary>We need to get the DHCPConfig as soon as possible so that we /// can allocate static addresses, this method helps us do that.</summary> protected override void GetDhcpConfig() { if(Interlocked.Exchange(ref _lock, 1) == 1) { return; } WaitCallback wcb = delegate(object o) { bool success = false; DHCPConfig dhcp_config = null; try { dhcp_config = DhtDhcpServer.GetDhcpConfig(AppNode.Dht, _ipop_config.IpopNamespace); success = true; } catch(Exception e) { ProtocolLog.WriteIf(IpopLog.DhcpLog, e.ToString()); } if(success) { lock(_sync) { _dhcp_config = dhcp_config; _dhcp_server = new DhtDhcpServer(AppNode.Dht, _dhcp_config, _ipop_config.EnableMulticast); } } base.GetDhcpConfig(); Interlocked.Exchange(ref _lock, 0); }; ThreadPool.QueueUserWorkItem(wcb); }