Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Windows Server AppFabric Service Validation

0.00/5 (No votes)
4 Feb 2012CPOL 12.8K  
How to test and Ensure that AppFabric Service is up and running
For Web applications, Windows Azure provides caching capabilities to provide high-speed access, scale, and high availability to application data. The AppFabric service "AppFabricCachingService" runs to accommodate the caching and session management infrastructure. The Cache cluster can be started using the powershell.

In order to validate that the service is up and running, the following test can be performed.

C#
namespace AppFabricServiceTest
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            IsServiceRunning();
        }

        private static bool IsServiceRunning()
        {
            bool status = false;
            var sc = new System.ServiceProcess.ServiceController("AppFabricCachingService");
            if (sc.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
                status = false;
            else
                status = true;

            return status;
        }
    }
}


You would need System.ServiceProcess assembly reference in your project to invoke ServiceController and check the status, i.e., ServiceControllerStatus. This enumeration provides various members including ContinuePending, Pause, PausePending, Running, StartPending, Stopped and StopPending.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)