public void Stop() { Log.WriteLine("stopping client"); isStopping = true; DisablePeerConnections(); Torrent.UpdateTrackers(TrackerEvent.Stopped, Id, Port); }
public void Start() { Log.WriteLine("starting client"); isStopping = false; Torrent.ResetTrackersLastRequest(); EnablePeerConnections(); // tracker thread new Thread(new ThreadStart(() => { while (!isStopping) { Torrent.UpdateTrackers(TrackerEvent.Started, Id, Port); Thread.Sleep(10000); } })).Start(); // peer thread new Thread(new ThreadStart(() => { while (!isStopping) { ProcessPeers(); Thread.Sleep(1000); } })).Start(); // upload thread new Thread(new ThreadStart(() => { while (!isStopping) { ProcessUploads(); Thread.Sleep(1000); } })).Start(); // download thread new Thread(new ThreadStart(() => { while (!isStopping) { ProcessDownloads(); Thread.Sleep(1000); } })).Start(); }