public void Execute() { Console.WriteLine("Downloading Files..."); var packs = gfpat.Execute(); var limitPacks = packs.Take(5); foreach (var pack in limitPacks) { ircClient.SendMessageToAll(pack.ToString()); Thread.Sleep(10000); var down = ircClient.CheckIfDownloading(); while (ircClient.CheckIfDownloading()) { Thread.Sleep(5000); } // Check filesize is correct before marking as done FileInfo fi = new FileInfo(Path.Combine(ps.settings.FolderInput, pack.Filename)); double packSize = 0; Double.TryParse(pack.Size, out packSize); // make sure the file exists and only differs by 1 mb (rounding) if (fi.Exists && Math.Abs(packSize - fi.Length / (1024 * 1024)) < 2) { db.files.TryAdd(fi.Name, new AnimeFile(fi.FullName)); db.FlushData(); } else { Console.WriteLine("Could not download: " + pack.Filename); } } ircClient.StopClient(); }