Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi all,
we currently fight some kind of company war related to threading and tasks.
It's all about a service that is used here for pulling emails.
On start a thread is launched that runs the Email-Puller wich internally uses several tasks to repeadly pull emails from several accounts (each account has one task).
 
Recently the service threw an exception leaving everything in a "miserable state".
 
Now several questions came up where we could not agree on a solution that fits best practices and stuff alike.
 
Currently the service just shuts down if an exception occurs.
Decision makers are fine with that, how surprising...
 
I told them that handling needs to be implemented to shut down each running task and then the main thread that runs if an error occurs. The Main-Thread could then be restarted so that the service keeps running. Decision makers just say nah, we just restart it because of time-related issues.
 
Is it possible that on such a failure some tasks are not automatically shut down if the service unexpectedly stops?
Besides the fact that a shutdown will not cause data-loss due to its implementation (worst case would be that an email would be pulled twice into our system) is that an acceptable way to let an application crash and rely on its sub-tasks/threads beeing shut down automatically?
 
What's your opinion, I'll be happy to hear them.
best regards
Andy
Posted 20-Nov-12 22:21pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi, there is a great a articale on threading here
now in my personal opinion each task must handle the exception that raising from the code been execued, meaning that the service must continue working while other threads raise exceptions. shutdown command can be issued but it must be because it has been intended
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100