Exemplo n.º 1
0
        public static void Terminate()
        {
            _sessionStatusDispatcherTimer.Stop();
            _sessionStatusDispatcherTimer.Dispose();
            _dispatcherTimer.Stop();
            _dispatcherTimer.Dispose();
            stopWeb();

            _torrentSession.pause();

            /* http://libtorrent.org/reference-Core.html#save_resume_data() */
            foreach (var item in TorrentHandles)
            {
                if (item.Value.is_valid())
                {
                    Core.TorrentStatus ts = item.Value.status();
                    if (ts.has_metadata && ts.need_save_resume)
                    {
                        /* http://libtorrent.org/reference-Core.html#save_resume_flags_t */
                        item.Value.save_resume_data(1 | 2 | 4);
                        ++outstanding_resume_data;
                    }
                }
            }
            no_more_resume = true;
            if (outstanding_resume_data != 0)
            {
                no_more_data.WaitOne();
            }
            TerminateSaveResume();
        }