Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm interested in what other people have to say, but I'll give you a few points that I've stumbled across:</p> <ol> <li><p>Make an event handler for Unhandled Exceptions. This way you can clean up resources, write to a log file, email an administrator, or anything you need to instead of having it crash.</p> <p>AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppUnhandledExceptionEventHandler);</p></li> <li><p>Override any servicebase event handlers you need in the main part of your application. OnStart and OnStop are pretty crucial, but there are many others you can use. <a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase%28v=VS.71%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase%28v=VS.71%29.aspx</a></p></li> <li><p>Beware of timers. Windows forms timers won't work right in a service. User System.Threading.Timers or System.Timers.Timer. <a href="https://stackoverflow.com/questions/246697/windows-service-and-timer">Best Timer for using in a Windows service</a></p></li> <li><p>If you are updating on a thread, make sure you use a lock() or monitor in key sections to make sure everything is threadsafe.</p></li> <li><p>Be careful not to use anything user specific, as a service runs without a specific user context. I noticed some of my SQL connection strings were no longer working for windows authorizations, etc. Also have heard people having trouble with mapped drives.</p></li> <li><p>Never make a service with a UI. In fact for Vista and 7 they make it nearly impossible to do anyway. It shouldn't require user interaction, the most you can do is send a message with a WIN32 function. MSDN claims making interactive services is bad practice. <a href="http://msdn.microsoft.com/en-us/library/ms683502%28VS.85%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms683502%28VS.85%29.aspx</a></p></li> <li><p>For debugging purposes, it is way cool to make a service run as a console application until you get it doing what you want it to. Awesome tutorial: <a href="http://mycomponent.blogspot.com/2009/04/create-debug-install-windows-service-in.html" rel="nofollow noreferrer">http://mycomponent.blogspot.com/2009/04/create-debug-install-windows-service-in.html</a></p></li> </ol> <p>Anyway, hope that helps a little, but that is just a couple thing I poked around to find on my own.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload