コード例 #1
0
ファイル: frmMain.cs プロジェクト: z3nth10n/HugeLauncher
        private static void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            form.BeginInvoke((MethodInvoker) delegate
            {
                DownloadPath dl = _downloads.Count > 0 ? _downloads.Dequeue() : null;
                if (dl != null && !cancellingDownload)
                {
                    NextDownload(dl);
                }
                else
                {
                    //Check if files are complete??
                    if (packType == PackType.Client)
                    {
                        frmMain.runClient = true;
                    }
                    else
                    {
                        frmMain.runServer = true;
                    }
                    frmMain.downloadingData = false;
                }

                DownloadCompleted(dl == null);
            });
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: z3nth10n/HugeLauncher
        private static void NextDownload(DownloadPath dl)
        {
            Thread thread = new Thread(() =>
            {
                curDownload = dl;
                string fol  = Path.GetDirectoryName(dl.Path);
                if (!Directory.Exists(fol))
                {
                    Directory.CreateDirectory(fol);
                }

                using (client = new WebClient())
                {
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadFileAsync(dl.Url, dl.Path);
                }
            });

            if (!cancellingDownload)
            {
                thread.Start();
            }
        }