|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
Thread.Priority-Eigenschaft
Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Eigenschaftswert
Typ: System.Threading.ThreadPriority| Ausnahme | Bedingung |
|---|---|
| ThreadStateException | |
| ArgumentException |
using System; using System.Threading; class Test { static void Main() { PriorityTest priorityTest = new PriorityTest(); ThreadStart startDelegate = new ThreadStart(priorityTest.ThreadMethod); Thread threadOne = new Thread(startDelegate); threadOne.Name = "ThreadOne"; Thread threadTwo = new Thread(startDelegate); threadTwo.Name = "ThreadTwo"; threadTwo.Priority = ThreadPriority.BelowNormal; threadOne.Start(); threadTwo.Start(); // Allow counting for 10 seconds. Thread.Sleep(10000); priorityTest.LoopSwitch = false; } } class PriorityTest { bool loopSwitch; public PriorityTest() { loopSwitch = true; } public bool LoopSwitch { set{ loopSwitch = value; } } public void ThreadMethod() { long threadCount = 0; while(loopSwitch) { threadCount++; } Console.WriteLine("{0} with {1,11} priority " + "has a count = {2,13}", Thread.CurrentThread.Name, Thread.CurrentThread.Priority.ToString(), threadCount.ToString("N0")); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.