protected override void Run() { // Connect the tunnel. InternalAnpTunnel = new AnpTunnel(Host, Port); Tunnel tunnel = InternalAnpTunnel.GetTunnel(); InternalAnpTunnel.BeginConnect(ReconnectHost, ReconnectPort); while (true) { SelectSockets set = new SelectSockets(); set.Timeout = 100; tunnel.CheckTls(); set.AddRead(tunnel.Sock); Block(set); if (set.ReadSockets.Contains(tunnel.Sock)) { InternalAnpTunnel.CreateTransport(); break; } } // Handle the tunnel. OnTunnelConnected(); }
/// <summary> /// Clean up the state when the session has completed to avoid resource /// leaks. This object CANNOT be reused for another session since some /// recently cancelled threads may still reference the object and try /// to modify its state. /// </summary> private void Terminate() { Status = VncSessionStatus.Completed; AppVnc.SessionPresentFlag = false; App.LocalSession = null; if (Overlay != null) { Overlay.Terminate(); Overlay = null; } if (TicketQuery != null) { TicketQuery.Terminate(); TicketQuery = null; } if (Tunnel != null) { Tunnel.Terminate(); Tunnel = null; } if (TunnelThread != null) { TunnelThread.RequestCancellation(); TunnelThread = null; } if (MainProcess != null) { MainProcess.Terminate(); MainProcess = null; } if (DummyProcess != null) { DummyProcess.Terminate(); DummyProcess = null; } if (Timer != null) { Timer.WakeMeUp(-1); Timer = null; } if (InactivityMonitor != null) { InactivityMonitor.Enabled = false; InactivityMonitor.Dispose(); InactivityMonitor = null; } }
public KcdThreadHost(KcdIdentifier kcdID) { KcdID = kcdID; Tunnel = new AnpTunnel(KcdID.Host, (int)KcdID.Port); }