HostProtectionAttribute.Synchronization Vlastnost

Definice

Získá nebo nastaví hodnotu označující, zda je synchronizace zpřístupněna.

C#
public bool Synchronization { get; set; }

Hodnota vlastnosti

truepokud je synchronizace zpřístupněna; v opačném případě . false Výchozí formát je false.

Příklady

Následující příklad kódu ukazuje použití atributu HostProtectionAttribute s Synchronization vlastností . Tento příklad je součástí většího příkladu poskytnutého HostProtectionAttribute pro třídu .

C#
// Use the enumeration flags to indicate that this method exposes 
// synchronization and external threading.
[HostProtectionAttribute(Synchronization=true, ExternalThreading=true)]
private static void StartThread()
{
    Thread t = new Thread(new ThreadStart(WatchFileEvents));
    
    // Start the new thread. On a uniprocessor, the thread is not given
    // any processor time until the main thread yields the processor.
    t.Start();
    
    // Give the new thread a chance to execute.
    Thread.Sleep(1000);
}

Platí pro

Viz také