Partager via


SynchronizationContext Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Provides the basic functionality for propagating a synchronization context in various synchronization models.

Inheritance Hierarchy

System.Object
  System.Threading.SynchronizationContext
    System.Windows.Threading.DispatcherSynchronizationContext

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Class SynchronizationContext
public class SynchronizationContext

The SynchronizationContext type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 SynchronizationContext Creates a new instance of the SynchronizationContext class.

Top

Properties

  Name Description
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Current Gets the synchronization context for the current thread.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 CreateCopy When overridden in a derived class, creates a copy of the synchronization context.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 OperationCompleted When overridden in a derived class, responds to the notification that an operation has completed.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 OperationStarted When overridden in a derived class, responds to the notification that an operation has started.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Post When overridden in a derived class, dispatches an asynchronous message to a synchronization context.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Send When overridden in a derived class, dispatches a synchronous message to a synchronization context.
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 SetSynchronizationContext Security Critical. Sets the current synchronization context.
Public methodStatic memberSupported by Silverlight for Windows Phone SetThreadStaticContext Obsolete. Security Critical. Sets the current context for thread static data.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

The SynchronizationContext class is a base class that provides a free-threaded context with no synchronization.

The purpose of the synchronization model implemented by this class is to allow the internal asynchronous/synchronization operations of the common language runtime to behave properly with different synchronization models. This model also simplifies some of the requirements that managed applications have had to follow in order to work correctly under different synchronization environments.

Providers of synchronization models can extend this class and provide their own implementations for these methods. 

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference