InstanceContext.SynchronizationContext Egenskap

Definition

Hämtar eller anger den kontext som används för trådsynkronisering med den aktuella instanskontexten.

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

Egenskapsvärde

Används SynchronizationContext för trådsynkronisering med den aktuella instanskontexten.

Undantag

Kommunikationsobjektet öppnas eller stängs och kan inte ändras i dessa tillstånd.

Kommunikationsobjektet har avbrutits och kan inte ändras i dessa tillstånd.

Kommunikationsobjektet har redan stängts och kan inte ändras i dessa tillstånd.

Kommunikationsobjektet är felaktigt och kan inte ändras i dessa tillstånd.

Exempel

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;
}

Gäller för