SynchronizationAttribute クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在のコンテキストと、同じインスタンスを共有するすべてのコンテキストに同期ドメインを適用します。
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
Public Class SynchronizationAttribute
Inherits ContextAttribute
Implements IContributeClientContextSink, IContributeServerContextSink
- 継承
- 属性
- 実装
例
次のコード例は、 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 つだけです。 これは、それぞれのコンテキストの着信呼び出しをインターセプトしてシリアル化するシンクを提供することによって行われます。 プロパティが再入のマークが付いている場合、吹き出しもインターセプトされます。 吹き出しインターセプトを使用すると、他の待機中のスレッドが最大スループットのために同期ドメインに入ることができます。
注
SynchronizationAttributeという名前の 2 つのクラスがあります。1 つはSystem.Runtime.Remoting.Contexts名前空間に、もう 1 つは System.EnterpriseServices 名前空間にあります。
System.EnterpriseServices.SynchronizationAttribute クラスは同期呼び出しのみをサポートし、サービス コンポーネントでのみ使用できます。
System.Runtime.Remoting.Contexts.SynchronizationAttributeは同期呼び出しと非同期呼び出しの両方をサポートしており、コンテキスト バインド オブジェクトでのみ使用できます。 (コンテキスト バインド オブジェクトの詳細については、 ContextBoundObject クラスを参照してください)。
注
このクラスは、クラス レベルでリンク要求と継承要求を行います。 SecurityExceptionは、直接呼び出し元または派生クラスにインフラストラクチャアクセス許可がない場合にスローされます。 セキュリティ要求の詳細については、「 リンク要求」を参照してください。
コンストラクター
| 名前 | 説明 |
|---|---|
| SynchronizationAttribute() |
既定値を使用して、 SynchronizationAttribute クラスの新しいインスタンスを初期化します。 |
| SynchronizationAttribute(Boolean) |
再入が必要かどうかを示すブール値を使用して、 SynchronizationAttribute クラスの新しいインスタンスを初期化します。 |
| SynchronizationAttribute(Int32, Boolean) |
この属性が適用されるオブジェクトの動作を示すフラグと、再入が必要かどうかを示すブール値を使用して、 SynchronizationAttribute クラスの新しいインスタンスを初期化します。 |
| SynchronizationAttribute(Int32) |
この属性が適用されるオブジェクトの動作を示すフラグを使用して、 SynchronizationAttribute クラスの新しいインスタンスを初期化します。 |
フィールド
| 名前 | 説明 |
|---|---|
| AttributeName |
この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。 コンテキスト属性の名前を示します。 (継承元 ContextAttribute) |
| NOT_SUPPORTED |
この属性が適用されるクラスを、同期を持つコンテキストで作成できないことを示します。 このフィールドは定数です。 |
| REQUIRED |
この属性を適用するクラスを、同期を持つコンテキストで作成する必要があることを示します。 このフィールドは定数です。 |
| REQUIRES_NEW |
この属性が適用されるクラスを、同期プロパティの新しいインスタンスを持つコンテキストで毎回作成する必要があることを示します。 このフィールドは定数です。 |
| SUPPORTED |
この属性が適用されるクラスが、コンテキストに同期があるかどうかに依存しないことを示します。 このフィールドは定数です。 |
プロパティ
| 名前 | 説明 |
|---|---|
| IsReEntrant |
再入が必要かどうかを示すブール値を取得または設定します。 |
| Locked |
このSynchronizationAttributeインスタンスを実装するContextがロックされているかどうかを示すブール値を取得または設定します。 |
| Name |
この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。 コンテキスト属性の名前を取得します。 (継承元 ContextAttribute) |
| TypeId |
派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。 (継承元 Attribute) |
メソッド
| 名前 | 説明 |
|---|---|
| Equals(Object) |
この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。 このインスタンスが指定したオブジェクトと等しいかどうかを示すブール値を返します。 (継承元 ContextAttribute) |
| Freeze(Context) |
この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。 コンテキストが固定されたときに呼び出されます。 (継承元 ContextAttribute) |
| GetClientContextSink(IMessageSink) |
CallOut シンクを作成し、リモート処理呼び出しのクライアント側のコンテキスト境界にある指定されたシンク チェーンの前にチェーンします。 |
| GetHashCode() |
この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。 ContextAttributeのこのインスタンスのハッシュコードを返します。 (継承元 ContextAttribute) |
| GetPropertiesForNewContext(IConstructionCallMessage) |
指定したIConstructionCallMessageに |
| GetServerContextSink(IMessageSink) |
同期されたディスパッチ シンクを作成し、リモート処理呼び出しのサーバー側のコンテキスト境界にあるシンクの指定されたチェーンの前にチェーンします。 |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| IsContextOK(Context, IConstructionCallMessage) |
コンテキスト パラメーターがコンテキスト属性の要件を満たしているかどうかを示すブール値を返します。 |
| 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) |