AsyncOperation.UserSuppliedState プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > AsyncOperation.UserSuppliedState プロパティの意味・解説 

AsyncOperation.UserSuppliedState プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

非同期操作一意識別するために使用するオブジェクト取得または設定します

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

Dim instance As AsyncOperation
Dim value As Object

value = instance.UserSuppliedState
public Object UserSuppliedState { get; }
public:
property Object^ UserSuppliedState {
    Object^ get ();
}
/** @property */
public Object get_UserSuppliedState ()
public function get UserSuppliedState
 () : Object

プロパティ
非同期メソッド呼び出し渡される状態オブジェクト

解説解説
使用例使用例

UserSuppliedState使用して非同期操作有効期間追跡するコード例次に示します。このコード例は、System.ComponentModel.AsyncOperationManager クラストピック取り上げているコード例一部分です。

import System.*;
import System.Collections.*;
import System.Collections.Specialized.*;
import System.ComponentModel.*;
import System.Threading.*;
' This method cancels a pending asynchronous operation.
Public Sub CancelAsync(ByVal
 taskId As Object)
    SyncLock userStateToLifetime.SyncRoot
        Dim obj As Object
 = userStateToLifetime(taskId)
        If Not (obj Is Nothing)
 Then
            Dim asyncOp As AsyncOperation =
 obj

            Dim numberToTest As Integer
 = 0
            Dim firstDivisor As Integer
 = 1
            Dim isPrime As Boolean
 = False
            Dim exception As Exception = Nothing
            Dim canceled As Boolean
 = True

            Dim e As New
 CalculatePrimeCompletedEventArgs( _
                numberToTest, _
                firstDivisor, _
                isPrime, _
                exception, _
                canceled, _
                asyncOp.UserSuppliedState)

            ' The asyncOp object is responsible for 
            ' marshalling the call to the proper 
            ' thread or context.
            asyncOp.PostOperationCompleted( _
            onCompletedDelegate, _
            e)
        End If
    End SyncLock

End Sub
// This method cancels a pending asynchronous operation.
public void CancelAsync(object taskId)
{
    lock (userStateToLifetime.SyncRoot)
    {
        object obj = userStateToLifetime[taskId];
        if (obj != null)
        {
            AsyncOperation asyncOp = obj as AsyncOperation;

            int numberToTest = 0;
            int firstDivisor = 1;
            bool isPrime = false;
            Exception exception = null;
            bool canceled = true;

            CalculatePrimeCompletedEventArgs e =
                new CalculatePrimeCompletedEventArgs(
                numberToTest,
                firstDivisor,
                isPrime,
                exception,
                canceled,
                asyncOp.UserSuppliedState);

            // The asyncOp object is responsible for 
            // marshaling the call to the proper 
            // thread or context.
            asyncOp.PostOperationCompleted(
                onCompletedDelegate,
                e);
        }
    }
}
public void CancelAsync(Object taskId)
{
    synchronized (userStateToLifetime.get_SyncRoot()) {
        Object obj = userStateToLifetime.get_Item(taskId);
        if (obj != null) {
            AsyncOperation asyncOp = (AsyncOperation)obj;

            int numberToTest = 0;
            int firstDivisor = 1;
            boolean isPrime = false;
            Exception exception = null;
            boolean cancelled = true;

            CalculatePrimeCompletedEventArgs e = 
                new CalculatePrimeCompletedEventArgs(numberToTest,
 
                firstDivisor, isPrime, exception, cancelled, 
                asyncOp.get_UserSuppliedState());
            // The asyncOp object is responsible for 
            // marshalling the call to the proper 
            // thread or context.
            asyncOp.PostOperationCompleted(onCompletedDelegate, e);
        }
    }
} //CancelAsync
public void CancelAsync(Object taskId)
{
    synchronized (userStateToLifetime.get_SyncRoot()) {
        Object obj = userStateToLifetime.get_Item(taskId);
        if (obj != null) {
            AsyncOperation asyncOp = (AsyncOperation)obj;
            int numberToTest = 0;
            int firstDivisor = 1;
            boolean isPrime = false;
            System.Exception exception = null;
            boolean cancelled = true;

            CalculatePrimeCompletedEventArgs e = 
                new CalculatePrimeCompletedEventArgs(numberToTest,
 
                firstDivisor, isPrime, exception, cancelled, 
                asyncOp.get_UserSuppliedState());
            // The asyncOp object is responsible for 
            // marshalling the call to the proper 
            // thread or context.
            asyncOp.PostOperationCompleted(onCompletedDelegate, e);
        }
    }
} //CancelAsync
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

AsyncOperation.UserSuppliedState プロパティのお隣キーワード
検索ランキング

   

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



AsyncOperation.UserSuppliedState プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS