المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : To use or not to use worker thread in Windows Service?



C# Programming
07-27-2010, 07:11 AM
I am a newbie to C# development (have been doing C++ for years) and Windows Service implementation.

While reading on the subject I found that there are 2 different approaches

1) Use timer event without additional worker thread - illustrated here: http://blogs.msdn.com/b/bclteam/archive/2005/03/15/396428.aspx[^ (http://blogs.msdn.com/b/bclteam/archive/2005/03/15/396428.aspx)]

2) Use worker thread - illustrated here: http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase%28VS.80%29.aspx[^ (http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase%28VS.80%29.aspx)]

I seem to find the first approach simpler and easier to use. Can anyone explain if there are any drawbacks for this approach?

Is there any reason to prefer worker thread approach?