SynchronizationAttribute クラス

定義

現在のコンテキスト、および同じインスタンスを共有するすべてのコンテキストの同期ドメインを適用します。

public ref class SynchronizationAttribute : System::Runtime::Remoting::Contexts::ContextAttribute, System::Runtime::Remoting::Contexts::IContributeClientContextSink, System::Runtime::Remoting::Contexts::IContributeServerContextSink
[System.AttributeUsage(System.AttributeTargets.Class)]
[System.Serializable]
public class SynchronizationAttribute : System.Runtime.Remoting.Contexts.ContextAttribute, System.Runtime.Remoting.Contexts.IContributeClientContextSink, System.Runtime.Remoting.Contexts.IContributeServerContextSink
[System.AttributeUsage(System.AttributeTargets.Class)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class SynchronizationAttribute : System.Runtime.Remoting.Contexts.ContextAttribute, System.Runtime.Remoting.Contexts.IContributeClientContextSink, System.Runtime.Remoting.Contexts.IContributeServerContextSink
[System.AttributeUsage(System.AttributeTargets.Class)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public class SynchronizationAttribute : System.Runtime.Remoting.Contexts.ContextAttribute, System.Runtime.Remoting.Contexts.IContributeClientContextSink, System.Runtime.Remoting.Contexts.IContributeServerContextSink
[<System.AttributeUsage(System.AttributeTargets.Class)>]
[<System.Serializable>]
type SynchronizationAttribute = class
    inherit ContextAttribute
    interface IContributeServerContextSink
    interface IContributeClientContextSink
[<System.AttributeUsage(System.AttributeTargets.Class)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SynchronizationAttribute = class
    inherit ContextAttribute
    interface IContributeServerContextSink
    interface IContributeClientContextSink
[<System.AttributeUsage(System.AttributeTargets.Class)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
type SynchronizationAttribute = class
    inherit ContextAttribute
    interface IContributeServerContextSink
    interface IContributeClientContextSink
[<System.AttributeUsage(System.AttributeTargets.Class)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SynchronizationAttribute = class
    inherit ContextAttribute
    interface IContributeClientContextSink
    interface IContributeServerContextSink
Public Class SynchronizationAttribute
Inherits ContextAttribute
Implements IContributeClientContextSink, IContributeServerContextSink
継承
SynchronizationAttribute
属性
実装

次のコード例では、 の使用方法を SynchronizationAttribute示します。 完全なコード例については、 クラスの例を AsyncResult 参照してください。

// Context-bound type with the Synchronization context attribute.

[Synchronization]
public ref class SampleSynchronized: public ContextBoundObject
{
public:

   // A method that does some work, and returns the square of the given number.
   int Square( int i )
   {
      Console::Write( "The hash of the thread executing " );
      Console::WriteLine( "SampleSynchronized::Square is: {0}", Thread::CurrentThread->GetHashCode() );
      return i * i;
   }

};
// Context-bound type with the Synchronization context attribute.
[Synchronization()]
public class SampleSynchronized : ContextBoundObject {

    // A method that does some work, and returns the square of the given number.
    public int Square(int i)  {

        Console.Write("The hash of the thread executing ");
        Console.WriteLine("SampleSynchronized.Square is: {0}",
                             Thread.CurrentThread.GetHashCode());
        return i*i;
    }
}
' Context-bound type with the Synchronization context attribute.
<Synchronization()> Public Class SampleSynchronized
   Inherits ContextBoundObject
   
   ' A method that does some work, and returns the square of the given number.
   Public Function Square(i As Integer) As Integer
      
      Console.Write("The hash of the thread executing ")
      Console.WriteLine("SampleSynchronized.Square is: {0}", Thread.CurrentThread.GetHashCode())
      Return i * i
   End Function 

End Class

注釈

この属性がオブジェクトに適用されている場合、このプロパティのインスタンスを共有するすべてのコンテキストで実行できるスレッドは 1 つだけです。 これは、それぞれのコンテキストの着信呼び出しをインターセプトしてシリアル化するシンクを提供することによって行われます。 プロパティが再入可能としてマークされている場合は、吹き出しもインターセプトされます。 吹き出しインターセプトを使用すると、他の待機中のスレッドが最大スループットのために同期ドメインに入ることができます。

Note

という名前 SynchronizationAttribute の 2 つのクラスがあります。1 つは System.Runtime.Remoting.Contexts 名前空間に、もう 1 つは 名前空間にあります System.EnterpriseServices 。 クラスは System.EnterpriseServices.SynchronizationAttribute 同期呼び出しのみをサポートし、サービス コンポーネントでのみ使用できます。 では System.Runtime.Remoting.Contexts.SynchronizationAttribute 同期呼び出しと非同期呼び出しの両方がサポートされており、コンテキスト バインド オブジェクトでのみ使用できます。 (コンテキスト バインド オブジェクトの詳細については、 クラスを ContextBoundObject 参照してください)。

Note

このクラスは、クラス レベルでリンク要求と継承要求を行います。 SecurityExceptionは、直接の呼び出し元または派生クラスにインフラストラクチャアクセス許可がない場合にスローされます。 セキュリティ要求の詳細については、「 リンク要求継承要求」を参照してください。

コンストラクター

SynchronizationAttribute()

SynchronizationAttribute クラスの新しいインスタンスを既定値で初期化します。

SynchronizationAttribute(Boolean)

再エントリが必要かどうかを示す Boolean 値を指定して、SynchronizationAttribute クラスの新しいインスタンスを初期化します。

SynchronizationAttribute(Int32)

この属性を適用するオブジェクトの動作を示すフラグを指定して、SynchronizationAttribute クラスの新しいインスタンスを初期化します。

SynchronizationAttribute(Int32, Boolean)

この属性を適用するオブジェクトの動作を示すフラグと、再エントリが必要かどうかを示す Boolean 値を指定して、SynchronizationAttribute クラスの新しいインスタンスを初期化します。

フィールド

AttributeName

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

コンテキスト属性の名前を示します。

(継承元 ContextAttribute)
NOT_SUPPORTED

この属性を適用したクラスを、同期を備えているコンテキスト内で作成できないことを示します。 このフィールドは定数です。

REQUIRED

この属性を適用したクラスを、同期を備えているコンテキスト内で作成する必要があることを示します。 このフィールドは定数です。

REQUIRES_NEW

この属性を適用したクラスを、同期プロパティの新しいインスタンスを使用して、コンテキスト内で毎回作成する必要があることを示します。 このフィールドは定数です。

SUPPORTED

この属性を適用したクラスが、コンテキストが同期を備えているかどうかに依存しないことを示します。 このフィールドは定数です。

プロパティ

IsReEntrant

再エントリが必要かどうかを示す Boolean 値を取得または設定します。

Locked

この Context のインスタンスを実装する SynchronizationAttribute がロックされているかどうかを示す Boolean 値を取得または設定します。

Name

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

コンテキスト属性の名前を取得します。

(継承元 ContextAttribute)
TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

対象のインスタンスが、指定したオブジェクトに等しいかどうかを示す Boolean 値を返します。

(継承元 ContextAttribute)
Freeze(Context)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

コンテキストが固定されるときに呼び出されます。

(継承元 ContextAttribute)
GetClientContextSink(IMessageSink)

CallOut シンクを作成し、リモート処理呼び出しのクライアント エンドのコンテキスト境界で提供されたシンク チェインの前にこれをチェインします。

GetHashCode()

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

ContextAttribute のこのインスタンスのハッシュコードを返します。

(継承元 ContextAttribute)
GetPropertiesForNewContext(IConstructionCallMessage)

Synchronized コンテキスト プロパティを、指定した IConstructionCallMessage に追加します。

GetServerContextSink(IMessageSink)

同期されたディスパッチ シンクを作成し、リモート処理呼び出しのサーバー エンドのコンテキスト境界で提供されたシンク チェインの前にこれをチェインします。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsContextOK(Context, IConstructionCallMessage)

コンテキスト パラメーターがコンテキスト属性の要件を満たしているかどうかを示す Boolean 値を返します。

IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
IsNewContextOK(Context)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

コンテキスト プロパティと新しいコンテキストとの間に互換性があるかどうかを示すブール値を返します。

(継承元 ContextAttribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象