473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

multithreading in web apps?

Can you do multi-threading in web applications? I basically understand how
to do it in winforms but am not sure about it in web apps. Can someone
point me to to an exmaple or an article that shows how?

Nov 19 '05 #1
4 1184
Edward,
Here is one article on this topic:
http://msdn.microsoft.com/msdnmag/is...g/default.aspx

I'd also like to say that multi-threading in ASP.NET is very similar to
doing it in a Windows app because you are executing .Net code in both
instances. If you just want to kick of a process and return the page
immediately, check out this sample I whipped up:

private void Page_Load(object sender, System.EventArgs e)

{

Thread thd = new Thread(new ThreadStart(LongRunning));

thd.Start();

//this.LongRunning();

Response.Write("Done " + DateTime.Now.ToString());

}

private void LongRunning()

{

Thread.Sleep(5000);

}
--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Edward W." <ed******@aol.comXSPAMMERIHATEYOU> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Can you do multi-threading in web applications? I basically understand how to do it in winforms but am not sure about it in web apps. Can someone
point me to to an exmaple or an article that shows how?

Nov 19 '05 #2
"Edward W." <ed******@aol.comXSPAMMERIHATEYOU> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Can you do multi-threading in web applications? I basically understand
how to do it in winforms but am not sure about it in web apps. Can
someone point me to to an exmaple or an article that shows how?


You should not attempt multithreading in web applications, except in very
limited circumstances. This has to do with the totally different lifecycle
between a web application and a winforms application. In particular, a Page
is an object which exists only for the duration of a request. When the
request is over, the page is gone. If you start a thread from that Page, it
should expect to execute after the page, and the request, are gone.

Leave multithreading out of web applications unless you have no other choice
or are an expert.

John Saunders
Nov 19 '05 #3
Yes you can do multithreading in ASP.NET, although the need should be very
rare since each page request is executed on a separate thread anyway.
Hre are a few tutorials you'll likely find to be useful:

http://msdn.microsoft.com/library/de...ingExample.asp

http://gethelp.devx.com/techtips/the...0min0201ma.asp

http://www.fawcette.com/vsm/2002_11/...tures/chester/

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Edward W." <ed******@aol.comXSPAMMERIHATEYOU> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Can you do multi-threading in web applications? I basically understand
how to do it in winforms but am not sure about it in web apps. Can
someone point me to to an exmaple or an article that shows how?

Nov 19 '05 #4
I agree that the need will rarely come up. One such need is if several
operations need to take place, and each one might take a bit of time. In
that case, all four could be started on separate threads, and the page could
return after all four threads complete their work. Of course, designing a
page like that would require more than intermediate skill with ASP.NET.

--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uS****************@TK2MSFTNGP11.phx.gbl...
Yes you can do multithreading in ASP.NET, although the need should be very
rare since each page request is executed on a separate thread anyway.
Hre are a few tutorials you'll likely find to be useful:

http://msdn.microsoft.com/library/de...ingExample.asp
http://gethelp.devx.com/techtips/the...0min0201ma.asp
http://www.fawcette.com/vsm/2002_11/...tures/chester/

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Edward W." <ed******@aol.comXSPAMMERIHATEYOU> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Can you do multi-threading in web applications? I basically understand
how to do it in winforms but am not sure about it in web apps. Can
someone point me to to an exmaple or an article that shows how?


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
3
by: Ed | last post by:
Here's my situation, I am moving some of my apps over from native C++ (primarily Win32 and MFC). One of these apps uses some COM objects in worker threads running in the background where it...
9
by: Popoxinhxan | last post by:
Dear experts, i want to develop an client application that consume the google search web service. In my MainForm i have a method to retrieve all the search result e.g. GetGoogleResults(). Now i...
9
by: tommy | last post by:
hi, i have found a example for multithreading and asp.net http://www.fawcette.com/vsm/2002_11/magazine/features/chester/ i want to speed up my website ... if my website is starting, they...
2
by: SStory | last post by:
Here is the situation. I want to display Icons, Type of file etc from a file extension. Upon initial program load I may only need icons for certain files. But other operations will require...
2
by: shonend | last post by:
**** sorry about the length of the message. If you can't read the whole thing and still willing to help, read the last 2 paragraphs where the main problem is described. The introduction story is...
6
by: MeowCow | last post by:
I will try and make my question with out being too long winded. I have been doing a lot of reading on how to do multithreading and I have implemented the code from the following example on...
2
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I...
0
by: Cilk | last post by:
We at Cilk Arts are soon (Jan '09) going to release Cilk++ 1.0, with the goal of delivering the easiest, quickest, and most reliable way to maximize application performance on multicore processors....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.