Esempio n. 1
0
        private void OnStatusChanged(BitSwarm.StatusChangedArgs e, Action <string> writeLog, Action onDownloadFinished)
        {
            const string EventType = "StatusChanged";

            writeLog($"[{EventType}] Status code: {e.Status}.{(e.ErrorMsg != string.Empty ? $" Error message: {e.ErrorMsg}." : string.Empty)}.");

            writeLog($"[{EventType}] Disposing BitSwarm...");
            _bitSwarm.Dispose();
            CleanUpFiles();
            onDownloadFinished.Invoke();
            writeLog($"[{EventType}] Done.");
        }
Esempio n. 2
0
        private static void BitSwarm_StatusChanged(object source, BitSwarm.StatusChangedArgs e)
        {
            if (e.Status == 0 && torrent != null && torrent.file.name != null)
            {
                Console.WriteLine($"\r\nDownload of {torrent.file.name} success!\r\n\r\n");
                Console.WriteLine(bitSwarm.DumpTorrent());
                Console.WriteLine($"\r\nDownload of {torrent.file.name} success!\r\n\r\n");
            }
            else if (e.Status == 2)
            {
                Console.WriteLine("An error has been occured :( \r\n" + e.ErrorMsg);
            }

            bitSwarm?.Dispose();
            bitSwarm        = null;
            sessionFinished = true;
        }
Esempio n. 3
0
        private void BitSwarm_StatusChanged(object source, BitSwarm.StatusChangedArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new Action(() => BitSwarm_StatusChanged(this, e)));
                return;
            }

            button1.Text = "Start";

            if (e.Status == 0)
            {
                string fileName = "";
                if (torrent.file.name != null)
                {
                    fileName = torrent.file.name;
                }
                if (torrent != null)
                {
                    torrent.Dispose(); torrent = null;
                }

                output.Text += "\r\n\r\nFinished at " + DateTime.Now.ToString("G", DateTimeFormatInfo.InvariantInfo);
                MessageBox.Show("Downloaded successfully!\r\n" + fileName);
            }
            else
            {
                output.Text += "\r\n\r\nStopped at " + DateTime.Now.ToString("G", DateTimeFormatInfo.InvariantInfo);

                if (e.Status == 2)
                {
                    output.Text += "\r\n\r\n" + "An error occurred :(\r\n\t" + e.ErrorMsg;
                    MessageBox.Show("An error occured :( \r\n" + e.ErrorMsg);
                }
            }

            if (torrent != null)
            {
                torrent.Dispose();
            }
        }