DeploymentProgressChangedEventArgs DeploymentProgressChangedEventArgs DeploymentProgressChangedEventArgs DeploymentProgressChangedEventArgs Class

定義

非同期操作で報告される進行状況データを表します。Represents progress data reported in an asynchronous operation.

public ref class DeploymentProgressChangedEventArgs : System::ComponentModel::ProgressChangedEventArgs
public class DeploymentProgressChangedEventArgs : System.ComponentModel.ProgressChangedEventArgs
type DeploymentProgressChangedEventArgs = class
    inherit ProgressChangedEventArgs
Public Class DeploymentProgressChangedEventArgs
Inherits ProgressChangedEventArgs
継承
DeploymentProgressChangedEventArgsDeploymentProgressChangedEventArgsDeploymentProgressChangedEventArgsDeploymentProgressChangedEventArgs

次のコード例は、という名前のファイル グループをダウンロードHelpFiles、およびステータス バーで進行状況のダウンロードが表示されます。The following code example downloads a file group named HelpFiles, and displays download progress in a status bar. この例は、Windows フォーム アプリケーションを展開して、メイン フォームに、StatusStripコントロール、およびToolStripStatusLabelという名前のコントロールdownloadStatusします。This example requires that you deploy a Windows Forms application, and that your main form has a StatusStrip control, and 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.");
    }
}
private void DownloadFileGroupAsync(string fileGroup)
{
    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

        try
        {
            if (!deployment.IsFileGroupDownloaded(fileGroup))
            {
                deployment.DownloadFileGroupProgressChanged += new DeploymentProgressChangedEventHandler(deployment_DownloadFileGroupProgressChanged);
                deployment.DownloadFileGroupCompleted += new DownloadFileGroupCompletedEventHandler(deployment_DownloadFileGroupCompleted);

                deployment.DownloadFileGroupAsync(fileGroup);
            }
        }
        catch (InvalidOperationException ioe)
        {
            MessageBox.Show("This application is not a ClickOnce application. Error: " + ioe.Message);
            return;
        }
    }
}

void deployment_DownloadFileGroupProgressChanged(object sender, DeploymentProgressChangedEventArgs e)
{
    downloadStatus.Text = String.Format("Downloading file group {0}; {1:D}K of {2:D}K completed.", e.Group, e.BytesCompleted / 1024, e.BytesTotal / 1024);               
}

void deployment_DownloadFileGroupCompleted(object sender, DownloadFileGroupCompletedEventArgs e)
{
    if (e.Error != null)
    {
        downloadStatus.Text = "Could not download files. Will try again later.";
        return;
    }
    else if (e.Cancelled)
    {
        downloadStatus.Text = "The file download has been cancelled.";
        return;
    }

    downloadStatus.Text = String.Format("Download of file group {0} complete.", e.Group);
}
Dim WithEvents ADDownloadHelpFiles As ApplicationDeployment

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

        If ADDownloadHelpFiles.IsFirstRun Then
            Try
                If Not ADDownloadHelpFiles.IsFileGroupDownloaded(GroupName) Then
                    ADDownloadHelpFiles.DownloadFileGroupAsync(GroupName)
                End If
            Catch ioe As InvalidOperationException
                MessageBox.Show("This application is not a ClickOnce application.")
                Return
            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

注釈

このクラスには進行状況を記述するプロパティが含まれています、 CheckForUpdateProgressChangedDownloadFileGroupProgressChanged、およびUpdateProgressChangedイベント。This class contains properties that describe progress for the CheckForUpdateProgressChanged, DownloadFileGroupProgressChanged, and UpdateProgressChanged events. このクラスのすべてのプロパティは、各イベントに適用されます。Not every property in this class applies to each event.

BytesCompleted BytesTotalそれぞれダウンロード日付とダウンロード操作のバイト数の合計数を表すバイトの合計数は 3 つすべてのイベントに適用します。BytesCompleted and BytesTotal represent the total number of bytes downloaded to date and the total number of bytes in the download operation, respectively; they apply to all three events. Group 現在に対応するファイル グループの名前を付けますDownloadFileGroupProgressChangedイベント、およびStateダウンロード操作の現在のステージが反映されます。Group names the file group corresponding to the current DownloadFileGroupProgressChanged event, and State reflects the current stage of the download operation.

プロパティ

BytesCompleted BytesCompleted BytesCompleted BytesCompleted

この操作によって既にダウンロードされているバイト数を取得します。Gets the number of bytes already downloaded by this operation.

BytesTotal BytesTotal BytesTotal BytesTotal

ダウンロード操作の合計バイト数を取得します。Gets the total number of bytes in the download operation.

Group Group Group Group

ダウンロードされるファイル グループの名前を取得します。Gets the name of the file group being downloaded.

ProgressPercentage ProgressPercentage ProgressPercentage ProgressPercentage

非同期タスクの進行状況の割合を取得します。Gets the asynchronous task progress percentage.

(Inherited from ProgressChangedEventArgs)
State State State State

プロセスが現在実行しているアクションを取得します。Gets the action that the process is currently executing.

UserState UserState UserState UserState

一意のユーザー状態を取得します。Gets a unique user state.

(Inherited from ProgressChangedEventArgs)

メソッド

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

適用対象

こちらもご覧ください