public void ChangePorts(ushort tcp, ushort udp) { if (Core.InvokeRequired) { Core.RunInCoreAsync(delegate() { ChangePorts(tcp, udp); }); return; } if (IsLookup) { Lookup.Ports.Tcp = tcp; Lookup.Ports.Udp = udp; } else { Core.User.Settings.TcpPort = tcp; Core.User.Settings.UdpPort = udp; } // re-initialize sockets UPnPControl.ClosePorts(); TcpControl.Shutdown(); UdpControl.Shutdown(); TcpControl.Initialize(); UdpControl.Initialize(); UPnPControl.Initialize(); // save profile if (Core.User != null) { Core.User.Save(); } // save lookup config if (IsLookup) { Lookup.Save(Core); } }