CpuCollection Class
The CpuCollection class represents a collection of Cpu objects that represent all the CPUs that are defined on an instance of SQL Server.
Assembly: Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
| Name | Description | |
|---|---|---|
![]() | AffitinizedCPUs | Gets an affinitized Cpu list. |
![]() | Count | Gets the number of Cpu entries in the collection. |
![]() | IsSynchronized | Gets a value that indicates whether the collection is synchronized with the instance of SQL Server. |
![]() | Item[Int32] | Gets a Cpu object from the collection. |
![]() | SyncRoot | Gets the synchronization root of the CpuCollection object. |
| Name | Description | |
|---|---|---|
![]() | CopyTo(Array^, Int32) | Copies the collection of objects to a one-dimensional array beginning at the specified index value. |
![]() | CopyTo(array<Cpu^>^, Int32) | Copies the collection of objects to a one-dimensional array beginning at the specified index value. |
![]() | Equals(Object^) | (Inherited from Object.) |
![]() | GetByID(Int32) | Gets a Cpu object with the specified CPU ID from the collection. |
![]() | GetElementAt(Int32) | Gets a Cpu object from the specified position in the collection. |
![]() | GetEnumerator() | Gets a T:System.IEnumerator interface that can be used to iterate over the CpuCollection object. |
![]() | GetHashCode() | (Inherited from Object.) |
![]() | GetType() | (Inherited from Object.) |
![]() | SetAffinityToAll(Boolean) | Sets the affinity mask for all CPUs on an instance of SQL Server. |
![]() | SetAffinityToRange(Int32, Int32, Boolean) | Sets the affinity mask for the CPUs in the specified range. |
![]() | SetAffinityToRange(Int32, Int32, Boolean, Boolean) | Sets the affinity mask for the CPUs in the specified range. |
![]() | ToString() | (Inherited from Object.) |
The methods T:Microsoft.SqlServer.Management.Smo.CpuCollection.Count,
T:Microsoft.SqlServer.Management.Smo.CpuCollection.IsSynchronized,
T:Microsoft.SqlServer.Management.Smo.CpuCollection.SyncRoot and
T:Microsoft.SqlServer.Management.Smo.CpuCollection.CopyTo(T:System.Array, T:System.Int32) are inherited from ICollection and IEnumerable.
The following example shows how to display the ID of each CPU on an 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();
//Display the ID of each CPU on the instance of SQL Server.
foreach (Cpu cpu in dbServer.AffinityInfo.Cpus)
{
Console.WriteLine("Cpu ID = {0}", cpu.ID);
}
}
}
}
Powershell
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.Refresh()
#Display the ID of each CPU on the instance of SQL Server.
Foreach ($cpu in $dbServer.AffinityInfo.Cpus)
{
Write-Host "CPU ID =" $cpu.ID
}
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

