Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
PIEBALDconsult26-Jul-10 9:20
mvePIEBALDconsult26-Jul-10 9:20 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
Gonzalo Cao26-Jul-10 20:46
Gonzalo Cao26-Jul-10 20:46 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
Chris Trelawny-Ross27-Jul-10 5:37
Chris Trelawny-Ross27-Jul-10 5:37 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
Gonzalo Cao27-Jul-10 8:28
Gonzalo Cao27-Jul-10 8:28 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
RugbyLeague26-Jul-10 23:34
RugbyLeague26-Jul-10 23:34 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
N a v a n e e t h27-Jul-10 0:54
N a v a n e e t h27-Jul-10 0:54 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
JoeSchmoe00727-Jul-10 3:04
JoeSchmoe00727-Jul-10 3:04 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
N a v a n e e t h27-Jul-10 4:51
N a v a n e e t h27-Jul-10 4:51 
JoeSchmoe007 wrote:
Can you elaborate why sleeping on the worker thread is bad design?


Because Thread.Sleep may or may not sleep for more time than you specified. Take a look at this[^] article.

IMO, the decision to use sleep is also subjective. If you need accuracy on the intervals, you should not use Thread.Sleep. If you are waitting for some condition to happen, say wait for an external device to be up, you should use WaitHandle instead of Thread.Sleep. Consider the following example:

A windows service which is expected to do some job at every 10 minutes accurately (Eg: downloading a webpage and indexing the contents). You start the service and 12.00 and it should run at 12.10, 12.20 and so on. Unfortunatly the work took 15 minutes to complete. Now the program won't run at 12.20 instead it will run at 12.35. You loose the accuracy!

This is where timers are useful.

JoeSchmoe007 wrote:
What design would you recommend instead


A windows service is something which is active all the time. If your application is doing the work only at specific intervals then it is not a good candidate for a service. It'd be better to create it as a normal console application and schedule it using the operating system's scheduler.


Smile | :)
Best wishes,
Navaneeth

QuestionResolved C# Socket programming with linux machine. [modified] Pin
jobin00700726-Jul-10 5:10
jobin00700726-Jul-10 5:10 
AnswerRe: C# Socket programming with linux machine. Pin
Richard MacCutchan26-Jul-10 6:13
mveRichard MacCutchan26-Jul-10 6:13 
AnswerRe: C# Socket programming with linux machine. Pin
PIEBALDconsult26-Jul-10 7:21
mvePIEBALDconsult26-Jul-10 7:21 
AnswerRe: Resolved C# Socket programming with linux machine. Pin
jobin00700727-Jul-10 5:33
jobin00700727-Jul-10 5:33 
QuestionWindows or Console application target for Windows Service? Pin
JoeSchmoe00726-Jul-10 3:43
JoeSchmoe00726-Jul-10 3:43 
AnswerRe: Windows or Console application target for Windows Service? Pin
darkelv26-Jul-10 4:04
darkelv26-Jul-10 4:04 
AnswerRe: Windows or Console application target for Windows Service? [modified] Pin
PIEBALDconsult26-Jul-10 6:55
mvePIEBALDconsult26-Jul-10 6:55 
QuestionMouse Hover/Leave with many controls and status strip message Pin
Blubbo26-Jul-10 3:05
Blubbo26-Jul-10 3:05 
AnswerRe: Mouse Hover/Leave with many controls and status strip message Pin
Blubbo26-Jul-10 4:16
Blubbo26-Jul-10 4:16 
QuestionFTP transfer corrupts .PNG files Pin
anthasaurus26-Jul-10 2:06
anthasaurus26-Jul-10 2:06 
AnswerRe: FTP transfer corrupts .PNG files Pin
Nagy Vilmos26-Jul-10 2:18
professionalNagy Vilmos26-Jul-10 2:18 
GeneralRe: FTP transfer corrupts .PNG files Pin
anthasaurus26-Jul-10 23:10
anthasaurus26-Jul-10 23:10 
QuestionSelection Formula in crystal report Pin
Nikhil Bhivgade26-Jul-10 1:21
professionalNikhil Bhivgade26-Jul-10 1:21 
QuestionWhat API to use? Pin
c242326-Jul-10 0:54
c242326-Jul-10 0:54 
AnswerRe: What API to use? Pin
Eddy Vluggen26-Jul-10 1:19
professionalEddy Vluggen26-Jul-10 1:19 
GeneralRe: What API to use? Pin
c242326-Jul-10 1:28
c242326-Jul-10 1:28 
GeneralRe: What API to use? Pin
Eddy Vluggen26-Jul-10 1:41
professionalEddy Vluggen26-Jul-10 1:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.