Esempio n. 1
0
        private async void GetUpdatedFile()
        {
            //preciso de arranjar maneira de mudar o caminho do ficheiro
            await Tmanager.StopAsync();

            await TorrentClientAPI.engine.Unregister(Tmanager);

            Tmanager.Dispose();
            PastaRoot.ChildFiles.Remove(this);
            File.Delete(Environment.CurrentDirectory + FilePath);
            FileModel NewFile = FSDatabaseFunctions.GetOneFile(FileID, NetID);

            FileVersion = NewFile.FileVersion;
            Tmanager    = NewFile.Tmanager;
            FilePath    = NewFile.FilePath;
            ToggleWillDownload();
            DEP           = new SqlDependency(new SqlCommand("Select * FROM Files WHERE FileID = " + FileID, ConnectionStuff.con));
            DEP.OnChange += new OnChangeEventHandler(FileChangedRemotelyEH);
            PastaRoot.ChildFiles.Add(this);
        }
        private static async Task ShutdownV2()
        {
            fastResume = new BEncodedDictionary();
            foreach (var Tmanager in engine.Torrents)
            {
                var stoppingTask = Tmanager.StopAsync();
                while (Tmanager.State != TorrentState.Stopped)
                {
                    Thread.Sleep(250);
                }
                await stoppingTask;
                if (Tmanager.HashChecked)
                {
                    fastResume.Add(Tmanager.Torrent.InfoHash.ToHex(), Tmanager.SaveFastResume().Encode());
                }
            }

            var nodes = await engine.DhtEngine.SaveNodesAsync();

            File.WriteAllBytes(dhtNodeFile, nodes);
            File.WriteAllBytes(fastResumeFile, fastResume.Encode());
            engine.Dispose();
            Thread.Sleep(2000);
        }