CpuCollection.SetAffinityToRange-Methode (Int32, Int32, Boolean)
Sets the affinity mask for the CPUs in the specified range.
Namespace: Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
Syntax
'Declaration
Public Sub SetAffinityToRange ( _
startCpuId As Integer, _
endCpuId As Integer, _
affinityMask As Boolean _
)
'Usage
Dim instance As CpuCollection
Dim startCpuId As Integer
Dim endCpuId As Integer
Dim affinityMask As Boolean
instance.SetAffinityToRange(startCpuId, _
endCpuId, affinityMask)
public void SetAffinityToRange(
int startCpuId,
int endCpuId,
bool affinityMask
)
public:
void SetAffinityToRange(
int startCpuId,
int endCpuId,
bool affinityMask
)
member SetAffinityToRange :
startCpuId:int *
endCpuId:int *
affinityMask:bool -> unit
public function SetAffinityToRange(
startCpuId : int,
endCpuId : int,
affinityMask : boolean
)
Parameter
- startCpuId
Typ: System.Int32
An int from 0 to Count -1 that specifies the beginning of the range of CPUs. If startIndex is not within the valid range, the following exception is returned: Specified argument was out of the range of valid values. Parameter name: startIndex.
- endCpuId
Typ: System.Int32
An int that specifies the endIndex of the range. endIndex must be greater than or equal to startIndex and less than [P:Microsoft.SqlServer.Management.Smo.CpuCollection.Count.]If endIndex is not within the valid range, the following exception is returned: Specified argument was out of the range of valid values. Parameter name: endIndexd.If endIndex is less than startIndex, the following exception is returned: The specified range of CPUs is not valid. The value for startIndex must be less than the value for endIndex.
- affinityMask
Typ: System.Boolean
If true, affinity is set to each CPU in the specified range. If false, affinity is removed from each CPU in the specified range.
Beispiele
The following example shows how to set the affinity to each CPU on an instance of SQL Server.
C#
using System;
using System.Collections.Specialized;
using System.Data;
using Microsoft.SqlServer.Management.Smo;
namespace samples
{
class Program
{
static void Main(string[] args)
{
Server dbServer = new Server("(local)");
dbServer.AffinityInfo.AffinityType = AffinityType.Manual;
dbServer.AffinityInfo.Alter();
dbServer.AffinityInfo.Cpus.SetAffinityToRange(0,
dbServer.AffinityInfo.Cpus.Count-1,
true);
}
}
}
Powershell
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.AffinityInfo.AffinityType = [Microsoft.SqlServer.Management.Smo.AffinityType]'Manual'
$dbServer.AffinityInfo.Alter()
$dbServer.AffinityInfo.Cpus.SetAffinityToRange(0, $dbServer.AffinityInfo.Cpus.Count-1, $TRUE)