ProcessInfo 类

定义

提供有关当前正在执行的进程的信息。Provides information on processes currently executing.

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

示例

下面的代码示例演示如何使用Age ShutdownReason ProcessID ProcessInfoPeakMemoryUsed的、 RequestCountStartTime 、、 Status和属性。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()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于