ApplicationDeployment::DownloadFileGroupCompleted Event
Occurs on the main application thread when a file download is complete.
Assembly: System.Deployment (in System.Deployment.dll)
The DownloadFileGroupCompleted event is called on the main application thread. It is thread safe to call your application's Windows Forms controls directly within this callback.
Check the Error property of the AsyncCompletedEventArgs supplied to this callback. If this property is nullptr, the download was successful; if it is not nullptr, the installation did not succeed, and you can find more information about the installation failure through the Error property.
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..
void LaunchAppUpdate() { if (ApplicationDeployment::IsNetworkDeployed) { ApplicationDeployment^ ad = ApplicationDeployment::CurrentDeployment; ad->UpdateCompleted += gcnew AsyncCompletedEventHandler(this, &Form1::LaunchAppUpdate_UpdateCompleted); ad->UpdateAsync(); } } void LaunchAppUpdate_UpdateCompleted(Object^ sender, AsyncCompletedEventArgs^ e) { if (!e->Cancelled) { if (nullptr != e->Error) { System::Windows::Forms::DialogResult dr = MessageBox::Show( "The application has been updated. Restart?", "Restart Application", MessageBoxButtons::OKCancel); if (System::Windows::Forms::DialogResult::OK == dr) { Application::Restart(); } } else { // Replace with your own error reporting or logging. MessageBox::Show( "The application encountered an error in " + "downloading the latest update. Error: {0}", e->Error->Message); } } else { // Replace with your own error reporting or logging. MessageBox::Show( "The update of the application's latest version was " + "cancelled."); } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.