public override void Disconnect() { /* 'this' is locked here and in RequestResult */ lock (this) { /* shut down discover thread */ if (DiscoverThread != null) { DiscoverThread.Abort(); } /* close connection thread */ if (ConnectionThread != null) { ConnectionThread.Abort(); } InKrakenNet = false; /* close all open connection */ foreach (KrakenNetConnection conn in Connections.Values) { conn.CloseConnection(); } Connections.Clear(); /* clear all found kraken hosts */ KrakenNodes.Clear(); /* close XMPP connection */ try { if (Client != null) { Client.Logout(); } } catch { } /* null these as last step */ Client = null; DiscoverThread = null; ConnectionThread = null; } }