ApplicationDeployment.DownloadFileGroupProgressChanged Event


Occurs when status information is available on a file download operation initiated by a call to DownloadFileGroupAsync.

Namespace:   System.Deployment.Application
Assembly:  System.Deployment (in System.Deployment.dll)

Public Event DownloadFileGroupProgressChanged As DeploymentProgressChangedEventHandler

The DownloadFileGroupProgressChanged event is called on the main application thread. It is thread safe to call your application's Windows Forms controls directly within this callback.

Use the information supplied in DeploymentProgressChangedEventArgs to communicate progress information to your users.

The following code example downloads a group of Help files in the background. The example requires that you deploy a Windows Forms application that includes a StatusStrip control, and that this control contain a ToolStripStatusLabel control named downloadStatus.

Dim WithEvents ADDownloadHelpFiles As ApplicationDeployment

Private Sub DownloadHelpFiles(ByVal GroupName As String)
    If (ApplicationDeployment.IsNetworkDeployed) Then
        ADDownloadHelpFiles = ApplicationDeployment.CurrentDeployment

        If ADDownloadHelpFiles.IsFirstRun Then
                If Not ADDownloadHelpFiles.IsFileGroupDownloaded(GroupName) Then
                End If
            Catch ioe As InvalidOperationException
                MessageBox.Show("This application is not a ClickOnce application.")
            End Try
        End If
    End If
End Sub

Private Sub ADDownloadHelpFiles_DownloadFileGroupProgressChanged(ByVal sender As Object, ByVal e As DeploymentProgressChangedEventArgs) Handles ADDownloadHelpFiles.DownloadFileGroupProgressChanged
    DownloadStatus.Text = String.Format("Downloading file group {0}; {1:D}K of {2:D}K completed.", e.Group, e.BytesCompleted / 1024, e.BytesTotal / 1024)
End Sub

Private Sub ADDownloadHelpFiles_DownloadFileGroupCompleted(ByVal sender As Object, ByVal e As DownloadFileGroupCompletedEventArgs) Handles ADDownloadHelpFiles.DownloadFileGroupCompleted
    DownloadStatus.Text = String.Format("Download of file group {0} complete.", e.Group)
End Sub

.NET Framework
Available since 2.0
Return to top