0

I'm looking to use lidgren in a simple chat server. Now I've looked at the samples in the lidgren source and have noticed the following,

  • For winforms apps they use the Application_Idle handler combined with the NativeMethods.AppStill Idle prop to manage running of the lidgren message pump

  • For console apps something similar is done via Console.IsKeyAvailable

My question is then what would be the suggested equivalent within a windows service application?

Chris Meek
  • 5,720
  • 9
  • 35
  • 44

1 Answers1

1

The Application.Idle event is handy to execute code on the UI thread that is least likely to affect the user interface. You can easily burn hundreds of milliseconds without the user noticing that the UI is stuttering.

This just isn't an issue in a service, it doesn't have a user interface. Just execute the code directly. If this is a polling type of operation (you don't have a good trigger or something you can wait on) then use a Timer.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536