By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

ASP.net multithreading?

P: n/a
Am I able to use ASP.net to multithread retrieve webpages?

Are there examples of using multithread in ASP.net?
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
This is a pretty vague question so it's a bit difficult to answer directly.
There is nothing to stop you from having an ASP.NET web page spawn separate
worker threads or to do asynchronous method processing using the underlying
..NET Threadpool.

However, without knowing exactly what it is you hope to accomplish, it would
be difficult to give more than the above "general" answer.

Provide some details, and get more detail in response.
Peter
"jty202" <jt****@gmail.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Am I able to use ASP.net to multithread retrieve webpages?

Are there examples of using multithread in ASP.net?

Nov 19 '05 #2

P: n/a
OK specifically, I have a list of webpages I want to retrieve and parse for
information.

I want to allow the user to select which sites to retrieve and parse. When
the user enters the selection, I want to spawn a thread to retreeve and
parse for each webpage. After each thread have finish parsing the data, it
puts the extracted data in one common data holder and the thread finishes.
When all the threads finished, I want to use the data holder to display the
data in results page. So thats the multithreading I want to do.
"jty202" <jt****@gmail.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Am I able to use ASP.net to multithread retrieve webpages?

Are there examples of using multithread in ASP.net?

Nov 19 '05 #3

P: n/a
jty202 wrote:
OK specifically, I have a list of webpages I want to retrieve and
parse for information.

I want to allow the user to select which sites to retrieve and parse.
When the user enters the selection, I want to spawn a thread to
retreeve and parse for each webpage. After each thread have finish
parsing the data, it puts the extracted data in one common data
holder and the thread finishes. When all the threads finished, I want
to use the data holder to display the data in results page. So thats
the multithreading I want to do.


Create a new System.Net.HttpWebRequest for each page you want to fetch.
Assuming you're just doing GET (not POST) requests, all you need to do is
call BeginGetResponse on each request and it will be processed by a worker
thread from the ASP.NET I/O pool.

The worker threads will call your AsyncCallback as each request completes
and you can get the stream and read the response into whatever structure
suits your needs.

Your main thread (the one that initiated all the GETs) will need to block on
a suitable synchronization structure that becomes signalled when all the
async requests have completed (or optionally, wakes up each time a request
complete and blocks again if more requests are still in flight).

-cd
Nov 19 '05 #4

P: n/a
Jty

You got a nice and in my opinion very good answer from Carl, I want to warn
you for what you are doing. Carl wrote already that your mainthread is
dependend from all your worker threads. However in a websolution you have
normally not one client who is active, it will give you a lot of
synchronization in my opinion.

I would first try it without the multithreading.

Only trying to prevent you from the hole a lot went in.

Cor
Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.