Поделиться через


Класс CpuCollection

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

Пространство имен:  Microsoft.SqlServer.Management.Smo
Сборка:  Microsoft.SqlServer.Smo (в Microsoft.SqlServer.Smo.dll)

Синтаксис

'Декларация
Public NotInheritable Class CpuCollection _
    Implements ICollection, IEnumerable
'Применение
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

Тип CpuCollection обеспечивает доступ к следующим элементам.

Свойства

  Имя Описание
Открытое свойство 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 Gets a Cpu object from the collection.
Открытое свойство SyncRoot Gets the synchronization root of the CpuCollection object.

В начало

Методы

  Имя Описание
Открытый метод 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.)
Защищенный метод Finalize (Производный от Object.)
Открытый метод GetByID Gets a Cpu object with the specified CPU ID from the collection.
Открытый метод GetElementAt Gets a Cpu object from the specified position in the collection.
Открытый метод GetEnumerator Gets a IEnumerator interface that can be used to iterate over the CpuCollection object.
Открытый метод GetHashCode (Производный от Object.)
Открытый метод GetType (Производный от Object.)
Защищенный метод MemberwiseClone (Производный от Object.)
Открытый метод SetAffinityToAll 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 (Производный от Object.)

В начало

Замечания

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
}

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.