public PeriodicTorrent AddTorrent(TorrentWrapper torrent) { var periodicTorrent = new PeriodicTorrent(torrent); Task.Factory.StartNew(() => { Client.Register(torrent); if (SettingsManager.StartTorrentsImmediately) torrent.Start(); }); Application.Current.Dispatcher.BeginInvoke(new Action(() => Torrents.Add(periodicTorrent))); return periodicTorrent; }
public PeriodicTorrent AddTorrent(TorrentWrapper torrent) { var periodicTorrent = new PeriodicTorrent(torrent); Torrents.Add(periodicTorrent); torrent.Index = Torrents.Count; Task.Factory.StartNew(() => { Client.Register(torrent); torrent.Start(); }); return periodicTorrent; }
public PeriodicTorrent AddTorrent(TorrentWrapper torrent, bool startImmediately) { // Apply settings torrent.Settings.UseDht = SettingsManager.EnableDHT; torrent.Settings.MaxConnections = SettingsManager.MaxConnectionsPerTorrent; torrent.Settings.MaxDownloadSpeed = SettingsManager.MaxDownloadSpeed; torrent.Settings.MaxUploadSpeed = SettingsManager.MaxUploadSpeed; torrent.Settings.UploadSlots = SettingsManager.UploadSlotsPerTorrent; var periodicTorrent = new PeriodicTorrent(torrent); Task.Factory.StartNew(() => { Client.Register(torrent); if (startImmediately) torrent.Start(); }); Application.Current.Dispatcher.BeginInvoke(new Action(() => Torrents.Add(periodicTorrent))); return periodicTorrent; }
public PeriodicTorrent AddTorrent(TorrentWrapper torrent, bool startImmediately) { // Apply settings torrent.Settings.UseDht = SettingsManager.EnableDHT; torrent.Settings.MaxConnections = SettingsManager.MaxConnectionsPerTorrent; torrent.Settings.MaxDownloadSpeed = SettingsManager.MaxDownloadSpeed; torrent.Settings.MaxUploadSpeed = SettingsManager.MaxUploadSpeed; torrent.Settings.UploadSlots = SettingsManager.UploadSlotsPerTorrent; var periodicTorrent = new PeriodicTorrent(torrent); Task.Factory.StartNew(() => { Client.Register(torrent); if (startImmediately) { torrent.Start(); } }); Application.Current.Dispatcher.BeginInvoke(new Action(() => Torrents.Add(periodicTorrent))); return(periodicTorrent); }
public void MoveTorrent(TorrentWrapper torrent, string path) { Task.Factory.StartNew(() => { path = Path.Combine(path, Path.GetFileName(torrent.Path)); if (!Directory.Exists(path)) Directory.CreateDirectory(path); var oldPath = torrent.Path; torrent.Stop(); while (torrent.State != TorrentState.Stopped) ; torrent.MoveFiles(path, true); torrent.Start(); Directory.Delete(oldPath, true); var cache = Path.Combine(SettingsManager.TorrentCachePath, Path.GetFileName(oldPath)); File.WriteAllText(Path.Combine(Path.GetDirectoryName(cache), Path.GetFileName(cache)) + ".info", path); }); }
public PeriodicTorrent LoadFastResume(FastResume resume, TorrentWrapper torrent) { var periodicTorrent = new PeriodicTorrent(torrent); Torrents.Add(periodicTorrent); torrent.Index = Torrents.Count; Task.Factory.StartNew(() => { torrent.LoadFastResume(resume); Client.Register(torrent); torrent.Start(); }); return periodicTorrent; }