コード例 #1
0
        static Top10Listener listener;           // This is a subclass of TraceListener which remembers the last 20 statements sent to it

        static void Main(string[] args)
        {
            // Uncomment this to run the stress test
            //
            //var tester = new StressTest ();
            //tester.RunAsync ().Wait ();

            /* Generate the paths to the folder we will save .torrent files to and where we download files to */
            basePath       = Environment.CurrentDirectory;                              // This is the directory we are currently in
            torrentsPath   = Path.Combine(basePath, "Torrents");                        // This is the directory we will save .torrents to
            downloadsPath  = Path.Combine(basePath, "Downloads");                       // This is the directory we will save downloads to
            fastResumeFile = Path.Combine(torrentsPath, "fastresume.data");
            dhtNodeFile    = Path.Combine(basePath, "DhtNodes");
            torrents       = new List <TorrentManager> ();                                              // This is where we will store the torrentmanagers
            listener       = new Top10Listener(10);

            // We need to cleanup correctly when the user closes the window by using ctrl-c
            // or an unhandled exception happens
            Console.CancelKeyPress += delegate { Shutdown().Wait(); };
            AppDomain.CurrentDomain.ProcessExit        += delegate { Shutdown().Wait(); };
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); Shutdown().Wait(); };
            Thread.GetDomain().UnhandledException      += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); Shutdown().Wait(); };

            StartEngine().Wait();
        }
コード例 #2
0
ファイル: main.cs プロジェクト: SICGames/monotorrent
        static Top10Listener listener;           // This is a subclass of TraceListener which remembers the last 20 statements sent to it

        static void Main(string[] args)
        {
            if (args.Length == 1 && MagnetLink.TryParse(args[0], out MagnetLink link))
            {
                new MagnetLinkStreaming().DownloadAsync(link).Wait();
                return;
            }

            // Uncomment this to run the stress test
            //
            //var tester = new StressTest ();
            //tester.RunAsync ().Wait ();

            torrentsPath  = Path.Combine(Environment.CurrentDirectory, "Torrents");                     // This is the directory we will save .torrents to
            downloadsPath = Path.Combine(Environment.CurrentDirectory, "Downloads");                    // This is the directory we will save downloads to
            torrents      = new List <TorrentManager> ();                                               // This is where we will store the torrentmanagers
            listener      = new Top10Listener(10);

            // We need to cleanup correctly when the user closes the window by using ctrl-c
            // or an unhandled exception happens
            Console.CancelKeyPress += delegate { Shutdown().Wait(); };
            AppDomain.CurrentDomain.ProcessExit        += delegate { Shutdown().Wait(); };
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); Shutdown().Wait(); };
            Thread.GetDomain().UnhandledException      += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); Shutdown().Wait(); };

            StartEngine().Wait();
        }
コード例 #3
0
        // This is a subclass of TraceListener which remembers the last 20 statements sent to it

        private static void Main(string[] args)
        {
            /* Generate the paths to the folder we will save .torrent files to and where we download files to */
            basePath = Environment.CurrentDirectory; // This is the directory we are currently in
            torrentsPath = Path.Combine(basePath, "Torrents"); // This is the directory we will save .torrents to
            downloadsPath = Path.Combine(basePath, "Downloads"); // This is the directory we will save downloads to
            fastResumeFile = Path.Combine(torrentsPath, "fastresume.data");
            dhtNodeFile = Path.Combine(basePath, "DhtNodes");
            torrents = new List<TorrentManager>(); // This is where we will store the torrentmanagers
            listener = new Top10Listener(10);

            // We need to cleanup correctly when the user closes the window by using ctrl-c
            // or an unhandled exception happens
            Console.CancelKeyPress += delegate { shutdown(); };
            AppDomain.CurrentDomain.ProcessExit += delegate { shutdown(); };
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e)
            {
                Console.WriteLine(e.ExceptionObject);
                shutdown();
            };
            Thread.GetDomain().UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e)
            {
                Console.WriteLine(e.ExceptionObject);
                shutdown();
            };

            StartEngine();
        }
コード例 #4
0
        static Top10Listener listener;           // This is a subclass of TraceListener which remembers the last 20 statements sent to it

        static void Main(string[] args)
        {
            /* Generate the paths to the folder we will save .torrent files to and where we download files to */
            basePath       = Environment.CurrentDirectory;                              // 程序所在的目录
            torrentsPath   = Path.Combine(basePath, "Torrents");                        // Torrent存储的目录
            downloadsPath  = Path.Combine(basePath, "Downloads");                       // 指定下载的目录
            fastResumeFile = Path.Combine(torrentsPath, "fastresume.data");
            dhtNodeFile    = Path.Combine(basePath, "DhtNodes");
            torrents       = new List <TorrentManager> ();                                              // 存储TorrentManager列表
            listener       = new Top10Listener(10);

            // 当用户使用 Ctrl - C 关闭窗口或发生未处理的异常时,我们需要正确处理
            Console.CancelKeyPress += delegate { Shutdown().Wait(); };
            AppDomain.CurrentDomain.ProcessExit        += delegate { Shutdown().Wait(); };
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); Shutdown().Wait(); };
            Thread.GetDomain().UnhandledException      += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); Shutdown().Wait(); };

            StartEngine().Wait();
        }
コード例 #5
0
ファイル: VLCStream.cs プロジェクト: xuesongTX/monotorrent
        }                                               // This is a subclass of TraceListener which remembers the last 20 statements sent to it

        public VLCStream(ClientEngine engine)
        {
            DownloadDirectory = "streaming_cache";
            Listener          = new Top10Listener(10);
            Engine            = engine;
        }
コード例 #6
0
        }                                               // This is a subclass of TraceListener which remembers the last 20 statements sent to it

        public StandardDownloader(ClientEngine engine)
        {
            Engine   = engine;
            Listener = new Top10Listener(10);
        }