Note that there are some explanatory texts on larger screens.

plurals
  1. POButton 1 works, button 2 is premature
    text
    copied!<p>I've got the following code. Button 1 is working correctly and launches after the download is fully complete. However button 2 is trying to launch at around 50% complete. Anyone have a clue as to why?</p> <pre><code>Imports System.Net Imports System.Threading Imports System.ComponentModel Public Class Form1 ' Occurs when an asynchronous file download operation completes. Private Sub _DownloadFileCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs) ' File download completed Button1.Text = "Launching..." Shell("C:\war.exe") End Sub Private Sub _DownloadFileCompleted2(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs) ' File download completed Button2.Text = "Launching..." Shell("C:\war.exe") End Sub ' Occurs when an asynchronous download operation successfully transfers some or all of the data. Private Sub _DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) ' Update progress bar ProgressBar1.Value = e.ProgressPercentage End Sub ' download button click event Private Sub download_button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click ' Disable download button to avoid clicking again while downloading the file Button1.Text = "Downloading Updates" Button2.Visible = False ' Downloads, to a local file, the resource with the specified URI. ' This method does not block the calling thread. Dim _WebClient As New WebClient() AddHandler _WebClient.DownloadFileCompleted, AddressOf _DownloadFileCompleted AddHandler _WebClient.DownloadProgressChanged, AddressOf _DownloadProgressChanged _WebClient.DownloadFileAsync(New Uri("http://www.url.com"), "C:\prog.exe") End Sub Private Sub download_button_Click2(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click ' Disable download button to avoid clicking again while downloading the file Button2.Text = "Downloading Updates" Button1.Visible = False ' Downloads, to a local file, the resource with the specified URI. ' This method does not block the calling thread. Dim _WebClient2 As New WebClient() AddHandler _WebClient2.DownloadFileCompleted, AddressOf _DownloadFileCompleted2 AddHandler _WebClient2.DownloadProgressChanged, AddressOf _DownloadProgressChanged _WebClient2.DownloadFileAsync(New Uri("http://www.url.com"), "C:\prog.exe") End Sub End Class </code></pre> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload