ProcessInfo 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供目前正在執行的流程資訊。
public ref class ProcessInfo
public class ProcessInfo
type ProcessInfo = class
Public Class ProcessInfo
- 繼承
-
ProcessInfo
範例
以下程式碼範例展示了使用Age類別的 PeakMemoryUsed 、 ProcessID、 RequestCountShutdownReasonStartTime和 StatusProcessInfo 屬性。 範例顯示一個 LinkButton。 點擊 時 LinkButton ,會顯示當前製程資訊。
<%@ Page language="c#" AutoEventWireup="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ASP.NET Example</title>
<script language="c#" runat="server">
void GetProcessInfo(Object sender, EventArgs e)
{
ProcessInfo pi;
// Get the current process information.
pi = ProcessModelInfo.GetCurrentProcessInfo();
Literal1.Text = "<p>Age: " + pi.Age + "</p>";
Literal1.Text += "<p>PeakMemoryUsed: " + pi.PeakMemoryUsed + "</p>";
Literal1.Text += "<p>ProcessID: " + pi.ProcessID + "</p>";
Literal1.Text += "<p>RequestCount: " + pi.RequestCount + "</p>";
Literal1.Text += "<p>ShutdownReason: " + pi.ShutdownReason + "</p>";
Literal1.Text += "<p>StartTime: " + pi.StartTime + "</p>";
Literal1.Text += "<p>Status: " + pi.Status + "</p>";
}
</script>
</head>
<body>
<form id="WebForm1" method="post" runat="server">
<asp:button id="Button1" OnClick="GetProcessInfo" runat="server" Text="Get Process Info"></asp:button>
<asp:Literal id="Literal1" runat="server"></asp:Literal>
</form>
</body>
</html>
<%@ Page language="vb" AutoEventWireup="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ASP.NET Example</title>
<script language="vb" runat="server">
Sub GetProcessInfo(sender As Object, e As System.EventArgs)
Dim pi As ProcessInfo
'Get information about the current process.
pi = ProcessModelInfo.GetCurrentProcessInfo()
Literal1.Text = "<p>Age: " & pi.Age.ToString & "</p>"
Literal1.Text = Literal1.Text & "<p>PeakMemoryUsed: " & pi.PeakMemoryUsed.ToString & "</p>"
Literal1.Text = Literal1.Text & "<p>ProcessID: " & pi.ProcessID.ToString & "</p>"
Literal1.Text = Literal1.Text & "<p>RequestCount: " & pi.RequestCount.ToString & "</p>"
Literal1.Text = Literal1.Text & "<p>ShutdownReason: " & pi.ShutdownReason.ToString & "</p>"
Literal1.Text = Literal1.Text & "<p>StartTime: " & pi.StartTime.ToString & "</p>"
Literal1.Text = Literal1.Text & "<p>Status: " & pi.Status.ToString & "</p>"
End Sub
</script>
</head>
<body>
<form id="WebForm2" method="post" runat="server">
<asp:button id="Button1" OnClick="GetProcessInfo" runat="server" Text="Get Process Info"></asp:button>
<asp:Literal id="Literal1" runat="server"></asp:Literal>
</form>
</body>
</html>
備註
此類別回傳在 ASP.NET 程序模型下運行的 ASP.NET 工作程序資訊。 此類物件由靜態方法 ProcessModelInfo.GetCurrentProcessInfo 和 ProcessModelInfo.GetHistory返回。 這些方法是建立初始化物件的唯一有用方法。
Note
如果你使用 Microsoft Internet Information Services (IIS) 6.0,ProcessInfo 類別回傳的流程指標只有在你以 IIS 5.0 隔離模式運行時才可用。 如果你使用 IIS 6.0 的 Worker Process 隔離模式,ASP.NET 流程模型會被停用,且當你存取 HttpException 成員時會拋出 ProcessInfo 例外。
建構函式
| 名稱 | Description |
|---|---|
| ProcessInfo() |
初始化 ProcessInfo 類別的新執行個體。 |
| ProcessInfo(DateTime, TimeSpan, Int32, Int32, ProcessStatus, ProcessShutdownReason, Int32) |
初始化該類別的新實例 ProcessInfo ,並設定內部資訊以指示程序的狀態。 |
屬性
| 名稱 | Description |
|---|---|
| Age |
能知道這個流程運行了多久。 |
| PeakMemoryUsed |
取得程序已使用的最大記憶體。 |
| ProcessID |
會拿到分配給流程的ID號碼。 |
| RequestCount |
會取得該程序的啟動請求數量。 |
| ShutdownReason |
會得到一個數值,說明程序關閉的原因。 |
| StartTime |
會知道流程開始的時間點。 |
| Status |
取得流程的當前狀態。 |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| SetAll(DateTime, TimeSpan, Int32, Int32, ProcessStatus, ProcessShutdownReason, Int32) |
設定內部資訊以指示程序狀態。 |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |