Cpu.AffinityMask 属性
Gets or sets the AffinityMask member of the Cpu class.
命名空间: Microsoft.SqlServer.Management.Smo
程序集: Microsoft.SqlServer.Smo(在 Microsoft.SqlServer.Smo.dll 中)
语法
声明
Public Property AffinityMask As Boolean
Get
Set
用法
Dim instance As Cpu
Dim value As Boolean
value = instance.AffinityMask
instance.AffinityMask = value
public bool AffinityMask { get; set; }
public:
property bool AffinityMask {
bool get ();
void set (bool value);
}
member AffinityMask : bool with get, set
function get AffinityMask () : boolean
function set AffinityMask (value : boolean)
属性值
类型:System.Boolean
Returns a Boolean that shows the current affinity mask setting for the CPU that is represented by this Cpu instance.
注释
Access to the Cpu class is though the Cpus collection.
To change the CPU settings on an instance of SQL Server, users must have ALTER permission on the database.
示例
The following code example shows how to display the affinity setting for each CPU in the local instance of SQL Server.
C#
using System;
using Microsoft.SqlServer.Management.Smo;
namespace samples
{
class Program
{
static void Main(string[] args)
{
Server dbServer = new Server("(local)");
dbServer.Refresh();
foreach(Cpu cpu in dbServer.AffinityInfo.Cpus)
Console.WriteLine("Affinity is {0} for CPU ID {1}.",
(cpu.AffinityMask) ? "set" : "not set",
cpu.ID);
}
}
}
Powershell
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.Refresh()
Foreach ($cpu in $dbServer.AffinityInfo.Cpus)
{
If ($cpu.AffinityMask = $TRUE)
{
Write-Host "Affinity is set for" $cpu.ID
}
Else
{
Write-Host "Affinity is not set for" $cpu.ID
}