Skip to content

Instantly share code, notes, and snippets.

@lextm
Created October 14, 2012 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lextm/3888301 to your computer and use it in GitHub Desktop.
Save lextm/3888301 to your computer and use it in GitHub Desktop.
Windows Service test sample
using System;
using System.ServiceProcess;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var service = new ServiceController("msiserver");
if (service.CanStop)
{
Console.WriteLine("idle");
}
else
{
Console.WriteLine("busy");
}
try
{
Mutex.OpenExisting("Global\\_MSIExecute");
Console.WriteLine("busy");
}
catch (WaitHandleCannotBeOpenedException)
{
Console.WriteLine("idle");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment