ProcessInfo 類別

定義

提供目前正在執行的處理序相關資訊。Provides information on processes currently executing.

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

範例

下列程式碼範例將示範如何Age使用PeakMemoryUsed Status StartTime ProcessID RequestCount ProcessInfo類別的、 ShutdownReason、、、和屬性。The following code example demonstrates using the Age, PeakMemoryUsed, ProcessID, RequestCount, ShutdownReason, StartTime and Status properties of the ProcessInfo class. 此範例會顯示LinkButtonThe example displays a LinkButton. LinkButton按一下時, 會顯示目前的處理常式資訊。When the LinkButton is clicked, the current process information is displayed.

<%@ 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>
            &nbsp;
      <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>
            &nbsp;
      <asp:Literal id="Literal1" runat="server"></asp:Literal>
    </form>
  </body>
</html>

備註

這個類別會傳回在 ASP.NET 進程模型下執行之 ASP.NET 工作者進程的相關資訊。This class returns information about ASP.NET worker processes that are running under the ASP.NET process model. 這個類型的物件是由靜態方法ProcessModelInfo.GetCurrentProcessInfoProcessModelInfo.GetHistory傳回。Objects of this type are returned by the static methods ProcessModelInfo.GetCurrentProcessInfo and ProcessModelInfo.GetHistory. 這些方法是建立初始化物件的唯一實用方式。These methods are the only useful ways to create an initialized object.

注意

如果您使用的是 Microsoft Internet Information Services (IIS) 6.0, 只有在 IIS 5.0 ProcessInfo隔離模式下執行時, 才可以使用這些類別所傳回的進程計量。If you are using Microsoft Internet Information Services (IIS) 6.0, process metrics returned by the ProcessInfo classes are available only if you are running in IIS 5.0 isolation mode. 如果您在背景工作進程隔離模式中使用 IIS 6.0, 則會停用 ASP.NET 進程模型HttpException , 而且當您存取ProcessInfo成員時, 會擲回例外狀況。If you are using IIS 6.0 in worker process isolation mode, the ASP.NET process model is disabled and an HttpException exception is thrown when you access ProcessInfo members.

建構函式

ProcessInfo()

初始化 ProcessInfo 類別的新執行個體。Initializes a new instance of the ProcessInfo class.

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

初始化 ProcessInfo 類別的新執行個體,並設定指示處理序狀態的內部資訊。Initializes a new instance of the ProcessInfo class and sets internal information indicating the status of the process.

屬性

Age

取得處理序已經執行的時間長度。Gets the length of time the process has been running.

PeakMemoryUsed

取得處理序已經使用的最大記憶體數量。Gets the maximum amount of memory the process has used.

ProcessID

取得指派給處理序的 ID 編號。Gets the ID number assigned to the process.

RequestCount

取得處理序的開始要求數。Gets the number of start requests for the process.

ShutdownReason

取得值,表示處理序為何關閉。Gets a value that indicates why the process shut down.

StartTime

取得處理序開始的時間。Gets the time at which the process started.

Status

取得處理序的目前狀態。Gets the current status of the process.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

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

設定內部資訊,表示處理序的狀態。Sets internal information indicating the status of the process.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於