hickensa
hickensa
CC#
Created by hickensa on 4/26/2024 in #help
why is this only occasionally async
private void button12_Click(object sender, EventArgs e)
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += Worker_DoVSC;
worker.RunWorkerAsync();
}

private void Worker_DoVSC(object sender, DoWorkEventArgs e)
{
Download_VSC();
}
private void Download_VSC()
{
this.BeginInvoke(new Action(() =>
{
label2.Text = "Downloading Visual Studio Code..."; label2.Refresh();
this.Hide();
dl = new WebClient();
dl.DownloadFileCompleted += dl_DownloadFileCompleted;
dl.DownloadProgressChanged += dl_DownloadProgressChanged;
this.Show();
dl.DownloadFileAsync(new Uri("https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user"), "C:\\Downloads\\VSCodeUserSetup.exe");
sw.Start();
}));
}
private void button12_Click(object sender, EventArgs e)
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += Worker_DoVSC;
worker.RunWorkerAsync();
}

private void Worker_DoVSC(object sender, DoWorkEventArgs e)
{
Download_VSC();
}
private void Download_VSC()
{
this.BeginInvoke(new Action(() =>
{
label2.Text = "Downloading Visual Studio Code..."; label2.Refresh();
this.Hide();
dl = new WebClient();
dl.DownloadFileCompleted += dl_DownloadFileCompleted;
dl.DownloadProgressChanged += dl_DownloadProgressChanged;
this.Show();
dl.DownloadFileAsync(new Uri("https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user"), "C:\\Downloads\\VSCodeUserSetup.exe");
sw.Start();
}));
}
the main reason for why I need this to be async is because it is an entire form with downloads that has a progress bar a total size and live updating download speed and current mb downloaded (the reason why there is a stopwatch) I have managed to get it to be this exact code here and async a few times although most of the time it isn't
84 replies