Share via


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
}

執行緒安全性

這個型別的任何公用 static (在 Visual Basic 中為 Shared) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。