0

私は次のコードを持っています。ボタン1は正しく機能しており、ダウンロードが完全に完了すると起動します。ただし、ボタン2は約50%完了して起動しようとしています。誰もが理由についての手がかりを持っていますか?

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

前もって感謝します

4

0 に答える 0