Delen via


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.

Inheritance Hierarchy

System.Object
  Microsoft.SqlServer.Management.Smo.CpuCollection

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Syntax

'Declaration
Public NotInheritable Class CpuCollection _
    Implements ICollection, IEnumerable
'Usage
Dim instance As CpuCollection
public sealed class CpuCollection : ICollection, 
    IEnumerable
public ref class CpuCollection sealed : ICollection, 
    IEnumerable
[<SealedAttribute>]
type CpuCollection =  
    class
        interface ICollection
        interface IEnumerable
    end
public final class CpuCollection implements ICollection, IEnumerable

The CpuCollection type exposes the following members.

Properties

  Name Description
Public property AffitinizedCPUs Gets an affinitized Cpu list.
Public property Count Gets the number of Cpu entries in the collection.
Public property IsSynchronized Gets a value that indicates whether the collection is synchronized with the instance of SQL Server.
Public property Item Gets a Cpu object from the collection.
Public property SyncRoot Gets the synchronization root of the CpuCollection object.

Top

Methods

  Name Description
Public method CopyTo(Array, Int32) Copies the collection of objects to a one-dimensional array beginning at the specified index value.
Public method CopyTo(array<Cpu[], Int32) Copies the collection of objects to a one-dimensional array beginning at the specified index value.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetByID Gets a Cpu object with the specified CPU ID from the collection.
Public method GetElementAt Gets a Cpu object from the specified position in the collection.
Public method GetEnumerator Gets a IEnumerator interface that can be used to iterate over the CpuCollection object.
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method SetAffinityToAll Sets the affinity mask for all CPUs on an instance of SQL Server.
Public method SetAffinityToRange(Int32, Int32, Boolean) Sets the affinity mask for the CPUs in the specified range.
Public method SetAffinityToRange(Int32, Int32, Boolean, Boolean) Sets the affinity mask for the CPUs in the specified range.
Public method ToString (Inherited from Object.)

Top

Remarks

The methods Count,

IsSynchronized,

SyncRoot and

[T:Microsoft.SqlServer.Management.Smo.CpuCollection.CopyTo(T:System.Array,T:System.Int32)] are inherited from ICollection and IEnumerable.

Examples

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
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.