ApplicationPool 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供方法和屬性,以設定和管理 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 、將物件放入屬性包中,並在頁面模組中顯示內容值。
服務模組:
// 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 |
取得或設定值,這個值表示目前應用程式集區中 Managed 應用程式的管線模式。 |
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() |
停止目前的應用程式集區。 |