Beispiel #1
0
        internal WaitHandle CloseFileStreams(TorrentManager manager)
        {
            var handle = new ManualResetEvent(false);

            IOLoop.Queue(delegate {
                // Process all pending reads/writes then close any open streams
                try
                {
                    _loopTask();
                    _writer.Close(manager.Torrent.Files);
                }
                catch (Exception ex)
                {
                    SetError(manager, Reason.WriteFailure, ex);
                }
                finally
                {
                    handle.Set();
                }
            });

            return(handle);
        }
Beispiel #2
0
        private void DhtEngineStateChanged(object o, EventArgs e)
        {
            if (dhtEngine.State != DhtState.Ready)
            {
                return;
            }

            MainLoop.Queue(() =>
            {
                foreach (var manager in torrents.Where(manager => manager.CanUseDht))
                {
                    dhtEngine.Announce(manager.InfoHash, Listener.Endpoint.Port);
                    dhtEngine.GetPeers(manager.InfoHash);
                }
            });
        }