ProcessInfo 類別

定義

提供目前正在執行的處理序相關資訊。

public ref class ProcessInfo
public class ProcessInfo
type ProcessInfo = class
Public Class ProcessInfo
繼承
ProcessInfo

範例

下列程式碼範例示範如何使用 Age 類別的 ProcessInfoPeakMemoryUsed ProcessID 、、 RequestCountShutdownReason StartTimeStatus 屬性。 此範例會顯示 LinkButtonLinkButton按一下 時,會顯示目前的進程資訊。

<%@ 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 傳回。 這些方法是建立初始化物件的唯一實用方式。

注意

如果您使用 Microsoft Internet Information Services (IIS) 6.0,只有在您在 IIS 5.0 隔離模式中執行時,類別所 ProcessInfo 傳回的進程計量才能使用。 如果您在背景工作進程隔離模式中使用 IIS 6.0,則會停用 ASP.NET 進程模型,並在 HttpException 存取 ProcessInfo 成員時擲回例外狀況。

建構函式

ProcessInfo()

初始化 ProcessInfo 類別的新執行個體。

ProcessInfo(DateTime, TimeSpan, Int32, Int32, ProcessStatus, ProcessShutdownReason, Int32)

初始化 ProcessInfo 類別的新執行個體,並設定指示處理序狀態的內部資訊。

屬性

Age

取得處理序已經執行的時間長度。

PeakMemoryUsed

取得處理序已經使用的最大記憶體數量。

ProcessID

取得指派給處理序的 ID 編號。

RequestCount

取得處理序的開始要求數。

ShutdownReason

取得值,表示處理序為何關閉。

StartTime

取得處理序開始的時間。

Status

取得處理序的目前狀態。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
SetAll(DateTime, TimeSpan, Int32, Int32, ProcessStatus, ProcessShutdownReason, Int32)

設定內部資訊,表示處理序的狀態。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於