資訊
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Stopwatch.GetTimestamp 方法

取得計時器機制中的目前刻度數。

命名空間: System.Diagnostics
組件: System (在 system.dll 中)

public static long GetTimestamp ()
public static long GetTimestamp ()
public static function GetTimestamp () : long
不適用。

傳回值

表示基礎計時器機制之刻度計數器值的長整數。

如果 Stopwatch 類別使用高解析度效能計數器,則 GetTimestamp 會傳回該計數器的目前值。如果 Stopwatch 類別使用系統計時器,則 GetTimestamp 會傳回 DateTime.Now 執行個體的目前 DateTime.Ticks 屬性。

下列範例說明如何利用 GetTimestamp 方法來設定效能計數器。

// Create the performance counter.
PerformanceCounter PC = new PerformanceCounter(categoryName, 
                                               counterName, 
                                               false);
// Initialize the counter.
PC.RawValue = Stopwatch.GetTimestamp();

// Create the performance counter.
PerformanceCounter pc = new PerformanceCounter(categoryName,
    counterName, false);
// Initialize the counter.
pc.set_RawValue(Stopwatch.GetTimestamp());

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支援 Microsoft .NET Framework 3.0。

.NET Framework

支援版本:3.0、2.0

XNA Framework

支援版本:1.0

社群新增項目

顯示:
© 2014 Microsoft