This documentation is archived and is not being maintained.

ApplicationDeployment.DownloadFileGroupCompleted Event

Note: This event is new in the .NET Framework version 2.0.

Occurs on the main application thread once a file download completes.

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

public:
event DownloadFileGroupCompletedEventHandler^ DownloadFileGroupCompleted {
	void add (DownloadFileGroupCompletedEventHandler^ value);
	void remove (DownloadFileGroupCompletedEventHandler^ value);
}
/** @event */
public void add_DownloadFileGroupCompleted (DownloadFileGroupCompletedEventHandler value)

/** @event */
public void remove_DownloadFileGroupCompleted (DownloadFileGroupCompletedEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

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 a null reference (Nothing in Visual Basic), the download was successful; if it is not a null reference (Nothing in Visual Basic), the installation did not succeed, and you can find more details on this through the Error property.

If you initiated the download with the DownloadFileGroupAsync method, you can use the UserState property to access any state information you passed in.

The following code example downloads a group of help files in the background. The example requires that you are deploying a Windows Forms application, and that this application contains a StatusStrip control, and it contains a ToolStripStatusPanelcontrol name 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 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Show: