Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

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

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
public final class CpuCollection implements ICollection, IEnumerable

The CpuCollection type exposes the following members.

  NameDescription
Public propertyAffitinizedCPUsGets an affinitized Cpu list.
Public propertyCountGets the number of Cpu entries in the collection.
Public propertyIsSynchronizedGets a value that indicates whether the collection is synchronized with the instance of SQL Server.
Public propertyItemGets a Cpu object from the collection.
Public propertySyncRootGets the synchronization root of the CpuCollection object.
Top
  NameDescription
Public methodCopyTo(Array, Int32)Copies the collection of objects to a one-dimensional array beginning at the specified index value.
Public methodCopyTo(Cpu[], Int32)Copies the collection of objects to a one-dimensional array beginning at the specified index value.
Public methodEquals (Inherited from Object.)
Public methodGetByIDGets a Cpu object with the specified CPU ID from the collection.
Public methodGetElementAtGets a Cpu object from the specified position in the collection.
Public methodGetEnumeratorGets a IEnumerator interface that can be used to iterate over the CpuCollection object.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodSetAffinityToAllSets the affinity mask for all CPUs on an instance of SQL Server.
Public methodSetAffinityToRange(Int32, Int32, Boolean)Sets the affinity mask for the CPUs in the specified range.
Public methodSetAffinityToRange(Int32, Int32, Boolean, Boolean)Sets the affinity mask for the CPUs in the specified range.
Public methodToString (Inherited from Object.)
Top

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.

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.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.