Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900