CheckForUpdateCompletedEventArgsとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CheckForUpdateCompletedEventArgsの意味・解説 

CheckForUpdateCompletedEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

CheckForUpdateAsync の呼び出しによって取得した詳細な更新情報表します

名前空間: System.Deployment.Application
アセンブリ: System.Deployment (system.deployment.dll 内)
構文構文

Public Class CheckForUpdateCompletedEventArgs
    Inherits AsyncCompletedEventArgs
Dim instance As CheckForUpdateCompletedEventArgs
public class CheckForUpdateCompletedEventArgs
 : AsyncCompletedEventArgs
public ref class CheckForUpdateCompletedEventArgs
 : public AsyncCompletedEventArgs
public class CheckForUpdateCompletedEventArgs
 extends AsyncCompletedEventArgs
public class CheckForUpdateCompletedEventArgs
 extends AsyncCompletedEventArgs
解説解説

CheckForUpdateCompletedEventArgs使用すると、最新バージョンに関する情報基づいて ClickOnce アプリケーションアップグレードするかどうか決定できます。UpdateAvailable は、新し更新存在するかどうかを示すブール値を返します。AvailableVersion プロパティは、新しバージョンバージョン番号提供し、MinimumRequiredVersion は、コンピュータインストールされている最も古いバージョン提供します。IsUpdateRequired は、利用できる最新更新ユーザーにとって必要かどうか表します最後に、UpdateSizeBytes は、更新合計サイズ表します

使用例使用例

UpdateAvailable使用してアプリケーション新し更新存在するかどうか判断しIsUpdateRequired使用してユーザー更新インストールするように要求するかどうか判断する方法次のコード例示します

Private sizeOfUpdate As Long
 = 0

Dim WithEvents ADUpdateAsync As
 ApplicationDeployment

Private Sub UpdateApplication()
    If (ApplicationDeployment.IsNetworkDeployed) Then
        ADUpdateAsync = ApplicationDeployment.CurrentDeployment

        ADUpdateAsync.CheckForUpdateAsync()
    End If
End Sub

Sub ADUpdateAsync_CheckForUpdateProgressChanged(ByVal
 sender As Object, ByVal
 e As DeploymentProgressChangedEventArgs) Handles ADUpdateAsync.CheckForUpdateProgressChanged
    DownloadStatus.Text = [String].Format("{0:D}K of {1:D}K downloaded.",
 e.BytesCompleted / 1024, e.BytesTotal / 1024)
End Sub


Sub ADUpdateAsync_CheckForUpdateCompleted(ByVal
 sender As Object, ByVal
 e As CheckForUpdateCompletedEventArgs) Handles ADUpdateAsync.CheckForUpdateCompleted
    If (e.Error IsNot Nothing) Then
        MessageBox.Show(("ERROR: Could not retrieve new version
 of the application. Reason: " + ControlChars.Lf + e.Error.Message +
 ControlChars.Lf + "Please report this error to the system administrator."))
        Return
    Else
        If (e.Cancelled = True) Then
            MessageBox.Show("The update was cancelled.")
        End If
    End If

    ' Ask the user if they would like to update the application now.
    If (e.UpdateAvailable) Then
        sizeOfUpdate = e.UpdateSizeBytes

        If (Not e.IsUpdateRequired) Then
            Dim dr As DialogResult = MessageBox.Show("An
 update is available. Would you like to update the application now?",
 "Update Available", MessageBoxButtons.OKCancel)
            If (System.Windows.Forms.DialogResult.OK = dr) Then
                BeginUpdate()
            End If
        Else
            MessageBox.Show("A mandatory update is available for
 your application. We will install the update now, after which we will save all
 of your in-progress data and restart your application.")
            BeginUpdate()
        End If
    End If
End Sub

Private Sub BeginUpdate()
    ADUpdateAsync = ApplicationDeployment.CurrentDeployment
    ADUpdateAsync.UpdateAsync()
End Sub


Sub ADUpdateAsync_UpdateProgressChanged(ByVal
 sender As Object, ByVal
 e As DeploymentProgressChangedEventArgs) Handles ADUpdateAsync.UpdateProgressChanged
    Dim progressText As String
 = String.Format("{0:D}K out of {1:D}K downloaded
 - {2:D}% complete", e.BytesCompleted / 1024, e.BytesTotal / 1024, e.ProgressPercentage)
    DownloadStatus.Text = progressText
End Sub


Sub ADUpdateAsync_UpdateCompleted(ByVal sender
 As Object, ByVal e As
 AsyncCompletedEventArgs) Handles ADUpdateAsync.UpdateCompleted
    If (e.Cancelled) Then
        MessageBox.Show("The update of the application's
 latest version was cancelled.")
        Exit Sub
    Else
        If (e.Error IsNot Nothing) Then
            MessageBox.Show("ERROR: Could not install the latest
 version of the application. Reason: " + ControlChars.Lf + e.Error.Message
 + ControlChars.Lf + "Please report this error to the system administrator.")
            Exit Sub
        End If
    End If

    Dim dr As DialogResult = MessageBox.Show("The
 application has been updated. Restart? (If you do not restart now, the new version
 will not take effect until after you quit and launch the application again.)", "Restart Application", MessageBoxButtons.OKCancel)
    If (dr = System.Windows.Forms.DialogResult.OK) Then
        Application.Restart()
    End If
End Sub
long sizeOfUpdate = 0;

private void UpdateApplication()
{
    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
        ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(ad_CheckForUpdateCompleted);
        ad.CheckForUpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_CheckForUpdateProgressChanged);

        ad.CheckForUpdateAsync();
    }
}

void  ad_CheckForUpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs
 e)
{
    downloadStatus.Text = String.Format("Downloading: {0}. {1:D}K of {2:D}K
 downloaded.", GetProgressString(e.State), e.BytesCompleted/1024, e.BytesTotal/1024);
   
}

string GetProgressString(DeploymentProgressState state)
{
    if (state == DeploymentProgressState.DownloadingApplicationFiles)
    {
        return "application files";
    } 
    else if (state == DeploymentProgressState.DownloadingApplicationInformation)
 
    {
        return "application manifest";
    } 
    else 
    {
        return "deployment manifest";
    }
}

void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs
 e)
{
    if (e.Error != null)
    {
        MessageBox.Show("ERROR: Could not retrieve new version
 of the application. Reason: \n" + e.Error.Message + "\nPlease report
 this error to the system administrator.");
        return;
    }
    else if (e.Cancelled == true)
    {
        MessageBox.Show("The update was cancelled.");
    }

    // Ask the user if they would like to update the application now.
    if (e.UpdateAvailable)
    {
        sizeOfUpdate = e.UpdateSizeBytes;

        if (!e.IsUpdateRequired)
        {
            DialogResult dr = MessageBox.Show("An update is available. Would
 you like to update the application now?\n\nEstimated Download Time: ", "Update
 Available", MessageBoxButtons.OKCancel);
            if (DialogResult.OK == dr)
            {
                BeginUpdate();
            }
        }
        else
        {
            MessageBox.Show("A mandatory update is available for
 your application. We will install the update now, after which we will save all
 of your in-progress data and restart your application.");
            BeginUpdate();
        }
    }
}

private void BeginUpdate()
{
    ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
    ad.UpdateCompleted += new AsyncCompletedEventHandler(ad_UpdateCompleted);

    // Indicate progress in the application's status bar.
    ad.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_UpdateProgressChanged);
}

void ad_UpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs
 e)
{
    String progressText = String.Format("{0:D}K out of {1:D}K downloaded - {2:D}%
 complete", e.BytesCompleted / 1024, e.BytesTotal / 1024, e.ProgressPercentage);
    downloadStatus.Text = progressText;
}

void ad_UpdateCompleted(object sender, AsyncCompletedEventArgs
 e)
{
    if (e.Cancelled)
    {
        MessageBox.Show("The update of the application's latest version was
 cancelled.");
        return;
    }
    else if (e.Error != null)
    {
        MessageBox.Show("ERROR: Could not install the latest version of the
 application. Reason: \n" + e.Error.Message + "\nPlease report this
 error to the system administrator.");
        return;
    }

    DialogResult dr = MessageBox.Show("The application has been updated. Restart?
 (If you do not restart now, the new version will not take effect
 until after you quit and launch the application again.)", "Restart Application", MessageBoxButtons.OKCancel);
    if (DialogResult.OK == dr)
    {
        Application.Restart();
    }
}
private:
    long sizeOfUpdate;


private:
    void Form1_Load(Object^ sender, System::EventArgs^ e)
    {
        DoUpdate();
    }

public:
    void DoUpdate()
    {
        if (ApplicationDeployment::IsNetworkDeployed)
        {
            ApplicationDeployment^ currentAppDeployment =
                ApplicationDeployment::CurrentDeployment;
            currentAppDeployment->CheckForUpdateCompleted +=
                gcnew CheckForUpdateCompletedEventHandler(
                this, &Form1::currentDeploy_CheckForUpdateCompleted);
            currentAppDeployment->CheckForUpdateAsync();
        }
    }

    // If update is available, fetch it.
    void currentDeploy_CheckForUpdateCompleted(Object^ sender
,
        CheckForUpdateCompletedEventArgs^ e)
    {
        if (nullptr != e->Error)
        {
            // Log error.
            return;
        }

        if (e->UpdateAvailable)
        {
            sizeOfUpdate = (long) e->UpdateSizeBytes;
            if (!e->IsUpdateRequired)
            {
                System::Windows::Forms::DialogResult 
                    updateDialogueResult = MessageBox::Show(
                    "An update is available.Would you like to update the"
 +
                    " application now?", "Update Available",
                    MessageBoxButtons::OKCancel);
                if (System::Windows::Forms::DialogResult::OK ==
 
                    updateDialogueResult)
                {
                    BeginUpdate();
                }
            }
            else
            {
                BeginUpdate();
            }
        }
    }

    void BeginUpdate()
    {
        ApplicationDeployment^ ad = ApplicationDeployment::CurrentDeployment;
        ad->UpdateCompleted +=
            gcnew AsyncCompletedEventHandler(
            this, &Form1::CurrentDeployment_UpdateCompleted);

        // Indicate progress in the application's status bar.
        ad->UpdateProgressChanged +=
            gcnew DeploymentProgressChangedEventHandler(this,
 
            &Form1::ad_ProgressChanged);

        ad->UpdateAsync();
    }

    void CurrentDeployment_UpdateCompleted(Object^ sender,
        AsyncCompletedEventArgs^ e)
    {
        if (!e->Cancelled)
        {
            if (nullptr != e->Error)
            {
                System::Windows::Forms::DialogResult 
                    restartDialogueResult = MessageBox::Show(
                    "The application has been updated. Restart?",
                    "Restart Application",
                    MessageBoxButtons::OKCancel);
                if (System::Windows::Forms::DialogResult::OK ==
 
                    restartDialogueResult)
                {
                    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.");
        }
    }

    void ad_ProgressChanged(Object^ sender,
        DeploymentProgressChangedEventArgs^ e)
    {
        String^ progressText =
            String::Format(
            "{0:D}K out of {1:D}K downloaded - {2:D}% complete",
            e->BytesCompleted / 1024, e->BytesTotal / 1024,
            e->ProgressPercentage);
        statusStrip1->Text = progressText;
    }
継承階層継承階層
System.Object
   System.EventArgs
     System.ComponentModel.AsyncCompletedEventArgs
      System.Deployment.Application.CheckForUpdateCompletedEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CheckForUpdateCompletedEventArgs メンバ
System.Deployment.Application 名前空間
ApplicationDeployment クラス

CheckForUpdateCompletedEventArgs プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ AvailableVersion まだインストールされていない最新バージョンバージョン番号取得します
パブリック プロパティ Cancelled  非同期操作キャンセルされたかどうかを示す値を取得します。 ( AsyncCompletedEventArgs から継承されます。)
パブリック プロパティ Error  非同期操作中に発生したエラーを示す値を取得します。 ( AsyncCompletedEventArgs から継承されます。)
パブリック プロパティ IsUpdateRequired 更新インストールする必要があるかどうかを示す値を取得します
パブリック プロパティ MinimumRequiredVersion ユーザーコンピュータインストールしておく必要のある最小バージョン取得します
パブリック プロパティ UpdateAvailable まだインストールされていない更新利用できるかどうかを示す値を取得します
パブリック プロパティ UpdateSizeBytes 利用できる更新サイズ取得します
パブリック プロパティ UserState  非同期タスク一意識別子取得します。 ( AsyncCompletedEventArgs から継承されます。)
参照参照

関連項目

CheckForUpdateCompletedEventArgs クラス
System.Deployment.Application 名前空間
ApplicationDeployment クラス

CheckForUpdateCompletedEventArgs メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CheckForUpdateCompletedEventArgs クラス
System.Deployment.Application 名前空間
ApplicationDeployment クラス

CheckForUpdateCompletedEventArgs メンバ

CheckForUpdateAsync の呼び出しによって取得した詳細な更新情報表します

CheckForUpdateCompletedEventArgs データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ AvailableVersion まだインストールされていない最新バージョンバージョン番号取得します
パブリック プロパティ Cancelled  非同期操作キャンセルされたかどうかを示す値を取得します。(AsyncCompletedEventArgs から継承されます。)
パブリック プロパティ Error  非同期操作中に発生したエラーを示す値を取得します。(AsyncCompletedEventArgs から継承されます。)
パブリック プロパティ IsUpdateRequired 更新インストールする必要があるかどうかを示す値を取得します
パブリック プロパティ MinimumRequiredVersion ユーザーコンピュータインストールしておく必要のある最小バージョン取得します
パブリック プロパティ UpdateAvailable まだインストールされていない更新利用できるかどうかを示す値を取得します
パブリック プロパティ UpdateSizeBytes 利用できる更新サイズ取得します
パブリック プロパティ UserState  非同期タスク一意識別子取得します。(AsyncCompletedEventArgs から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CheckForUpdateCompletedEventArgs クラス
System.Deployment.Application 名前空間
ApplicationDeployment クラス


このページでは「.NET Framework クラス ライブラリ リファレンス」からCheckForUpdateCompletedEventArgsを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCheckForUpdateCompletedEventArgsを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCheckForUpdateCompletedEventArgs を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CheckForUpdateCompletedEventArgs」の関連用語

CheckForUpdateCompletedEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CheckForUpdateCompletedEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS