Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
WorkerProcess Property
Collapse the table of content
Expand the table of content

WorkerProcess Property

Gets the worker process that the application domain resides in.

Namespace:  Microsoft.Web.Administration
Assembly:  Microsoft.Web.Administration (in Microsoft.Web.Administration.dll)

public WorkerProcess WorkerProcess { get; }

Property Value

Type: Microsoft.Web.Administration..::..WorkerProcess
The WorkerProcess object that the application domain was created in.

To view all worker processes on a server, use the ServerManager..::..WorkerProcesses property.

The following example demonstrates how to view all properties and unload an application domain.

using System;
using Microsoft.Web.Administration;

namespace AdministrationSnippets
{
    public class MicrosoftWebAdministrationApplicationDomain
    {
        ServerManager manager = new ServerManager();

        public void RecycleApplicationDomains()
        {
            Console.WriteLine("Displaying Worker Processes & Application Domains...");
            GetApplicationDomains();

            Console.WriteLine("Unloading all application domains");
            UnloadApplicationDomains();

            Console.WriteLine("Displaying Worker Processes & Application Domains with new IDs...");
            GetApplicationDomains();
        }
        public void UnloadApplicationDomains()
        {
            foreach (WorkerProcess proc in manager.WorkerProcesses)
            {
                foreach (ApplicationDomain ad in proc.ApplicationDomains)
                {
                    ad.Unload();
                }
            }
        }
        public void GetApplicationDomains()
        {
            foreach (WorkerProcess proc in manager.WorkerProcesses)
            {
                Console.WriteLine("Worker Process Found:");
                Console.WriteLine("\tProcessId:   {0}", proc.ProcessId);
                Console.WriteLine("\tProcessGuid: {0}", proc.ProcessGuid);
                Console.WriteLine("\tAppPoolName: {0}", proc.AppPoolName);
                Console.WriteLine("\tApplication Domains:");
                foreach (ApplicationDomain ad in proc.ApplicationDomains)
                {
                    Console.WriteLine("\t\tApplication Domain Found:");
                    Console.WriteLine("\t\t{0}", ad.Id );
                    Console.WriteLine("\t\t{0}", ad.VirtualPath );
                    Console.WriteLine("\t\t{0}", ad.PhysicalPath );
                    Console.WriteLine("\t\t{0}", ad.Idle);
                }
            }
        }
    }
}


Community Additions

ADD
Show:
© 2015 Microsoft