Is this the correct Multi-threading approach

P

Pete

Hi,
I need to kick off a long running process in response to a user action
on my website. I'm not fussed whether it completes correctly or not (it's
just sends a load of emails) but I want control of the webpage to return
immediately to the user.

So all I do in my Server side event handler for the page is :

SiteUsers su = new SiteUsers();
Thread background = new Thread(new ThreadStart(su.EmailUsers));

background.Start();

Will this give me any undesirable side effects in ASP.NET? As I said earlier
I don't care if it completes or not so I've not used any Callback to tell me
when it's done.

thanks

Pete
 
K

Kevin Spencer

Should be just fine.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
J

John Saunders

Kevin Spencer said:
Should be just fine.

Should be just fine assuming that the new thread doesn't reference anything
from the page which spawned it, or from the current request.
 
J

John Timney \(Microsoft MVP\)

Just a thought Pete - what happens if its accessed by many users - will it
kill your box? In theory it should work fine, however if it was me I would
look at putting this into a windows service and using the web service to do
nothing more than log a job request. That was there is no risk whatsoever
to your web server.

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------
 
P

Pete

Yeah, I'd thought of that but for the time being at least the area is very
low use (i wanted the threading more for positive user perception, nothing
worse than a page that takes 5 seconds or more...).

The other issue I have is that I'm running on a Discount ASP.NET provider
who doesn't let me do too much so I need to be a bit creative to fix some
limitations ;) in server accessibility
Thanks for the heads-up though

Regards

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,745
Messages
2,569,485
Members
44,907
Latest member
PremiumScotch

Latest Threads

Top