Error in background task

Topics: Customizing Orchard, General, Troubleshooting, Writing modules
Dec 12, 2012 at 7:41 AM
Edited Dec 13, 2012 at 3:54 AM

Running some background tasks in Orchard:

public class SoftwareUpdateGenerator : IOrchardShellEvents

 

Time to time, it maybe 2 weeks or 1 month,  I get an error like this below and whole Orchard website is not working. As I can see there is an error in Orchard itself, not my bad.

Can you tell me what can be wrong?

Looking into log:

http://pastebin.com/ddfUXX5J

 

EDIT:

Found that it is discouraged to use background tasks. Is it recommended to use Scheduled tasks instead of creating threads for tasks ?

Coordinator
Dec 14, 2012 at 2:10 AM

Well, yes, spinning your own threads is in general a bad idea, and using what Orchard provides is hugely preferable.

Dec 14, 2012 at 2:23 AM

I don't use my own threads. I use Orchard background tasks implementing IOrchardShellEvents interface!

Coordinator
Dec 14, 2012 at 2:26 AM

Now you got me totally confused. What did you mean by "Is it recommended to use Scheduled tasks instead of creating threads for tasks ?" then?

Dec 14, 2012 at 11:59 AM
Edited Dec 14, 2012 at 12:00 PM

Guy at SO created tasks by implementing IOrchardShellEvents. You said not doing this:

http://stackoverflow.com/questions/13778217/a-background-running-feature-in-orchard

Coordinator
Dec 14, 2012 at 8:19 PM

I didn't. I said "the answer to any question beginning with "how do I spin a separate thread in order to..." is "don't". Seriously. See for example http://ayende.com/blog/158945/thou-shall-not-do-threading-unless-you-know-what-you-are-doing" I said nothing about IOrchardShellEvents.

I was warning against spinning your own threads.

You asked "Is it recommended to use Scheduled tasks instead of creating threads for tasks ?" to which I answered "spinning your own threads is in general a bad idea" and to which you answered "I don't use my own threads". Hence my confusion.