Aracılığıyla paylaş


ProcessThread.IdealProcessor Özellik

Tanım

Bu iş parçacığının üzerinde çalışması için tercih edilen işlemciyi ayarlar.

public:
 property int IdealProcessor {  void set(int value); };
public int IdealProcessor { set; }
[System.ComponentModel.Browsable(false)]
public int IdealProcessor { set; }
member this.IdealProcessor : int
[<System.ComponentModel.Browsable(false)>]
member this.IdealProcessor : int
Public Property IdealProcessor As Integer

Özellik Değeri

Sistem iş parçacıklarını zamanladığında, iş parçacığının hangi işlemcide çalıştırılabileceğini belirlemek için kullanılan iş parçacığı için tercih edilen işlemci.

Öznitelikler

Özel durumlar

Sistem, iş parçacığını belirtilen işlemcide başlatacak şekilde ayarlayamadı.

İşlem uzak bir bilgisayarda gerçekleştirilir.

Örnekler

Aşağıdaki örnekte, Not Defteri örneğinin özelliğinin IdealProcessor ilk işlemciye nasıl ayarlanacağı gösterilmektedir.

using System;
using System.Diagnostics;

namespace ProcessThreadIdealProcessor
{
    class Program
    {
        static void Main(string[] args)
        {
            // Make sure there is an instance of notepad running.
            Process[] notepads = Process.GetProcessesByName("notepad");
            if (notepads.Length == 0)
                Process.Start("notepad");
            ProcessThreadCollection threads;
            //Process[] notepads;
            // Retrieve the Notepad processes.
            notepads = Process.GetProcessesByName("Notepad");
            // Get the ProcessThread collection for the first instance
            threads = notepads[0].Threads;
            // Set the properties on the first ProcessThread in the collection
            threads[0].IdealProcessor = 0;
            threads[0].ProcessorAffinity = (IntPtr)1;
        }
    }
}
Imports System.Diagnostics



Class Program
    
    Shared Sub Main(ByVal args() As String) 
        ' Make sure there is an instance of notepad running.
        Dim notepads As Process() = Process.GetProcessesByName("notepad")
        If notepads.Length = 0 Then
            Process.Start("notepad")
        End If
        Dim threads As ProcessThreadCollection
        'Process[] notepads;
        ' Retrieve the Notepad processes.
        notepads = Process.GetProcessesByName("Notepad")
        ' Get the ProcessThread collection for the first instance
        threads = notepads(0).Threads
        ' Set the properties on the first ProcessThread in the collection
        threads(0).IdealProcessor = 0
        threads(0).ProcessorAffinity = CType(1, IntPtr)
    End Sub
End Class

Açıklamalar

Değer IdealProcessor sıfır tabanlıdır. Başka bir deyişle, ilk işlemcinin iş parçacığı benzini ayarlamak için özelliğini sıfır olarak ayarlayın.

Sistem, mümkün olduğunda iş parçacıklarını tercih ettikleri işlemcilerde zamanlar.

bir işlem iş parçacığı işlemciden işlemciye geçiş yapabilir ve her geçiş işlemci önbelleğini yeniden yükler. İş parçacığı için bir işlemci belirtmek, işlemci önbelleğinin yeniden yüklenme sayısını azaltarak ağır sistem yükleri altında performansı artırabilir.

Şunlara uygulanır