ProcessInfo 类

定义

提供有关当前正在执行的进程的信息。

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

示例

下面的代码示例演示如何使用类的 AgePeakMemoryUsedProcessIDRequestCountShutdownReasonStartTimeStatusProcessInfo属性。 该示例显示一个 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.GetCurrentProcessInfoProcessModelInfo.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)

适用于