ProcessThread.IdealProcessor 속성

정의

이 스레드가 실행될 기본 설정 프로세서를 설정합니다.

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

속성 값

스레드를 실행할 프로세서를 결정하기 위해 시스템에서 스레드를 예약할 때 사용하는 스레드의 기본 설정 프로세서입니다.

특성

예외

지정한 프로세스에서 스레드가 시작되도록 설정할 수 없는 경우

프로세스가 원격 컴퓨터에 있는 경우

예제

다음 예에서는 메모장의 instance 속성을 첫 번째 프로세서로 설정하는 IdealProcessor 방법을 보여 줍니다.

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

설명

값은 IdealProcessor 0부터 시작합니다. 즉, 첫 번째 프로세서에 대한 스레드 선호도를 설정하려면 속성을 0으로 설정합니다.

시스템은 가능하면 원하는 프로세서에서 스레드를 예약합니다.

프로세스 스레드는 프로세서 캐시를 다시 로드할 때마다 프로세서에서 프로세서로 마이그레이션할 수 있습니다. 스레드에 대한 프로세서를 지정하면 프로세서 캐시가 다시 로드되는 횟수를 줄여 시스템 부하가 많은 상태에서 성능을 향상시킬 수 있습니다.

적용 대상