The download function downloads async so that the UI doesn't freeze, but I need it to download one file at a time, so I have a second function called downloadall() that needs to call the download function, then wait fo the file to be downoaded and installed (this is a bool variable), then call the download function again
public void Download()
{
using (WebClient wc = new WebClient())
{
wc.Credentials = new NetworkCredential(User, Password);
wc.DownloadProgressChanged += wc_DownloadProgressChanged;
wc.DownloadFileAsync
(
new System.Uri(DownloadURL),
path + Name + ".zip"
);
}
}
private void DownloadAllBtn_Click(object sender, EventArgs e)
{
foreach (Pakage p in Program.Pakages)
{
if (!p.IsInstalled)
{
Download(p);
}
while (!p.IsInstalled)
{
///wait without freezing UI
}
}
}