InstanceContext.SynchronizationContext Eigenschaft

Definition

Ruft den für die Threadsynchronisierung mit dem aktuellen Instanzkontext verwendeten Kontext ab oder legt ihn fest.

public:
 property System::Threading::SynchronizationContext ^ SynchronizationContext { System::Threading::SynchronizationContext ^ get(); void set(System::Threading::SynchronizationContext ^ value); };
public System.Threading.SynchronizationContext SynchronizationContext { get; set; }
member this.SynchronizationContext : System.Threading.SynchronizationContext with get, set
Public Property SynchronizationContext As SynchronizationContext

Eigenschaftswert

SynchronizationContext

Der für die Threadsynchronisierung mit dem aktuellen Instanzkontext verwendete SynchronizationContext.

Ausnahmen

Das Kommunikationsobjekt ist geöffnet oder geschlossen und kann in diesen Zuständen nicht geändert werden.

Das Kommunikationsobjekt wurde abgebrochen und kann nicht in diesen Zuständen geändert werden.

Das Kommunikationsobjekt wurde bereits geschlossen und kann nicht in diesen Zuständen geändert werden.

Das Kommunikationsobjekt ist fehlerhaft und kann nicht in diesen Zuständen geändert werden.

Beispiele

Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
    serviceHost.Open();
    OperationContext operationContext = OperationContext.Current;
    InstanceContext instanceContext = operationContext.InstanceContext;
    SynchronizationContext syncCon = instanceContext.SynchronizationContext;
}

Gilt für