views:

230

answers:

3

Just wondering if anyone has had any trouble using a BackgroundWorker Thread in a site running under IIS 7 in Integrated Pipeline mode?

I am trying to use such a beast to update the database schema (admin function, obviously), and it works perfectly in Cassini, but when I deploy to IIS 7, the thread gets about one line of code in and silently ends. Is there a way to tell why a thread ended?

Thanks in advance.

+1  A: 

It is probably an exception. Perhaps you're running with different set of rights between the two environments.

Brian Rasmussen
Ah... the penny drops! Of course, Cassini runs under my user account (a machine admin), while the IIS7 process is a non-privileged user. Now why didn't I think of that? Thanks heaps.
Darren Oster
+2  A: 

I don't know but I have to ask: why do you use BackgroundWorker in first place? Its main purpose is to ease the threading on UI elements. Instead why don't you use a "normal" thread or any other non-UI mechanism?

Miha Markic
Fair call - probably too much time working in WPF and WinForms apps, I guess. These things can be habit-forming...
Darren Oster
+1  A: 

You do not want to use BackgroundWorker, Thomas from ASP.NET team just posted some information about executing code in separate threads in ASP.NET: http://blogs.msdn.com/tmarq/archive/2010/04/14/performing-asynchronous-work-or-tasks-in-asp-net-applications.aspx

CarlosAg