ApplicationPool 类

定义

提供用于配置和管理 IIS 7 应用程序池的方法和属性。

public ref class ApplicationPool sealed : Microsoft::Web::Administration::ConfigurationElement
public sealed class ApplicationPool : Microsoft.Web.Administration.ConfigurationElement
type ApplicationPool = class
    inherit ConfigurationElement
Public NotInheritable Class ApplicationPool
Inherits ConfigurationElement
继承
ApplicationPool

示例

以下示例实现 类的多个方法和属性 ApplicationPool 。 此示例检索 ApplicationPool 服务模块中的对象,修改对象的属性值 ApplicationPool ,将对象放入属性包中,并在页面模块中显示属性值。

服务模块:

// Gets the application pool collection from the server.
[ModuleServiceMethod(PassThrough = true)]
public ArrayList GetApplicationPoolCollection()
{
    // Use an ArrayList to transfer objects to the client.
    ArrayList arrayOfApplicationBags = new ArrayList();

    ServerManager serverManager = new ServerManager();
    ApplicationPoolCollection applicationPoolCollection = serverManager.ApplicationPools;
    foreach (ApplicationPool applicationPool in applicationPoolCollection)
    {
        PropertyBag applicationPoolBag = new PropertyBag();
        applicationPoolBag[ServerManagerDemoGlobals.ApplicationPoolArray] = applicationPool;
        arrayOfApplicationBags.Add(applicationPoolBag);
        // If the applicationPool is stopped, restart it.
        if (applicationPool.State == ObjectState.Stopped)
        {
            applicationPool.Start();
        }
        // Set the CPU limit to a maximum of 25.
        if (applicationPool.Cpu.Limit > 25)
        {
            applicationPool.Cpu.Limit = 25;
        }
        // Set the process model max process to 1 to prohibit Web Garden
        if (applicationPool.ProcessModel.MaxProcesses > 1)
        {
            applicationPool.ProcessModel.MaxProcesses = 1;
        }
        // Set the recycling time to a maximum of one day (1440 minutes).
        if (applicationPool.Recycling.PeriodicRestart.Time.TotalMinutes > 1440)
        {
            applicationPool.Recycling.PeriodicRestart.Time = TimeSpan.FromMinutes(1440);
        }
    }

    // CommitChanges to persist the changes to the ApplicationHost.config.
    serverManager.CommitChanges();
    return arrayOfApplicationBags;
}

页面模块:

// Get the ApplicationPool collection
ArrayList applicationPoolCollectionArray = _serviceProxy.GetApplicationPoolCollection();
string applicationdisplay = null;
applicationdisplay = "\nThere are " +
    applicationPoolCollectionArray.Count.ToString() + " applicationPools.\n";
foreach (PropertyBag bag in applicationPoolCollectionArray)
{
    ApplicationPool applicationPool = (ApplicationPool)bag[ServerManagerDemoGlobals.ApplicationPoolArray];
    applicationdisplay += "  " + applicationPool.Name + ":\n";
    applicationdisplay += "    FrameworkVersion - " + applicationPool.ManagedRuntimeVersion + "\n";
    applicationdisplay += "    State: " + applicationPool.State + "\n";
    applicationdisplay += "    WorkerProcesses: " + applicationPool.WorkerProcesses.Count + "\n";
    foreach (WorkerProcess workerProcess in applicationPool.WorkerProcesses)
    {
        applicationdisplay += "       " + workerProcess.ToString() + "\n";
    }
    applicationdisplay += "    CPU limit: " + applicationPool.Cpu.Limit.ToString() + "\n";
    applicationdisplay += "    MaxProcesses: " + applicationPool.ProcessModel.MaxProcesses.ToString() + "\n";
    applicationdisplay += "    Restart time: " + applicationPool.Recycling.PeriodicRestart.Time.TotalMinutes + "\n\n";
}

注解

此类提供应用程序池的配置和管理功能。 此类的属性通常直接对应于 IIS 7 配置系统中 applicationPools 配置元素的属性。

应用程序池与辅助进程关联,包含一个或多个应用程序,并在不同的应用程序间提供隔离。

属性

Attributes

获取包含此元素的属性列表的配置属性集合。

(继承自 ConfigurationElement)
AutoStart

获取或设置一个值,该值指示当前应用程序池是否在 IIS 启动时自动启动。

ChildElements

获取当前元素的所有子元素。

(继承自 ConfigurationElement)
Cpu

获取当前应用程序池的 CPU 使用率参数。

ElementTagName

提供用于配置和管理 IIS 7 应用程序池的方法和属性。

(继承自 ConfigurationElement)
Enable32BitAppOnWin64

获取或设置一个值,该值指示是否允许 32 位应用程序在具有 64 位处理器的计算机上运行。

Failure

获取在当前应用程序池发生故障时要执行的操作。

IsLocallyStored

获取一个值,该值指示配置元素是否存储在特定的配置文件中。

(继承自 ConfigurationElement)
Item[String]

获取或设置具有指定名称的属性。

(继承自 ConfigurationElement)
ManagedPipelineMode

获取或设置一个值,该值指示当前应用程序池中托管应用程序的管道模式。

ManagedRuntimeVersion

获取或设置用于当前应用程序池中托管应用程序的.NET Framework的版本。

Methods

获取配置元素的方法集合。

(继承自 ConfigurationElement)
Name

获取或设置当前应用程序池的名称。

ProcessModel

获取当前应用程序池的进程管理属性。

QueueLength

获取或设置在拒绝请求之前在应用程序池中排队的最大请求数。

RawAttributes

提供用于配置和管理 IIS 7 应用程序池的方法和属性。

(继承自 ConfigurationElement)
Recycling

获取当前应用程序池的回收设置。

Schema

获取当前元素的架构。

(继承自 ConfigurationElement)
StartMode

提供用于配置和管理 IIS 7 应用程序池的方法和属性。

State

获取当前应用程序池的运行时状态。

WorkerProcesses

获取为当前应用程序池提供服务的工作进程集合。

方法

Delete()

提供用于配置和管理 IIS 7 应用程序池的方法和属性。

(继承自 ConfigurationElement)
GetAttribute(String)

返回一个 ConfigurationAttribute 对象,该对象表示请求的属性。

(继承自 ConfigurationElement)
GetAttributeValue(String)

返回指定特性的值。

(继承自 ConfigurationElement)
GetChildElement(String)

返回当前配置元素下且具有指定名称的子元素。

(继承自 ConfigurationElement)
GetChildElement(String, Type)

返回一个子元素,该子元素位于当前配置元素下,具有指定的名称和类型。

(继承自 ConfigurationElement)
GetCollection()

返回当前配置元素的默认集合。

(继承自 ConfigurationElement)
GetCollection(String)

返回属于当前配置元素的所有配置元素。

(继承自 ConfigurationElement)
GetCollection(String, Type)

返回具有指定名称和类型的配置元素,并且位于当前配置元素下。

(继承自 ConfigurationElement)
GetCollection(Type)

返回具有指定类型且位于当前配置元素下的配置元素。

(继承自 ConfigurationElement)
GetMetadata(String)

从元素架构返回元数据值。

(继承自 ConfigurationElement)
Recycle()

回收当前应用程序池。

SetAttributeValue(String, Object)

设置所指定特性的值。

(继承自 ConfigurationElement)
SetMetadata(String, Object)

设置元素架构中的元数据值。

(继承自 ConfigurationElement)
Start()

启动当前应用程序池。

Stop()

停止当前应用程序池。

适用于

另请参阅