I’m using C# to write a WCF router which I want to stay running without using the Console.ReadKey “hack”. I was wondering if there’s an accepted way to do this within C# that’s more elegant than
while (true)
Thread.Sleep(100);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
create a
windows serviceproject. windows services have persistent lifecycle as compared to standard windows client.You can get started here.
From msdn:
After the service has been loaded, it must be started. Starting the service allows it to begin functioning. You can start a service from the Services Control Manager, from Server Explorer, or from code by calling the Start method. The Start method passes processing to the application’s OnStart method and processes any code you have defined there.
A running service can exist in this state indefinitely until it is either stopped or paused or until the computer shuts down.A service can exist in one of three basic states: Running, Paused, or Stopped. You can query the Status to determine what state a service is in.