Created
October 14, 2012 11:32
-
-
Save lextm/3888301 to your computer and use it in GitHub Desktop.
Windows Service test sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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