473,396 Members | 1,846 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,396 software developers and data experts.

Threading in Web Applications


If I put a ThreadStart on a ThreadPool, triggered by a button on a web
form, and I close the web form -- will the method on the Thread run to
completion?

Is it possible to build a web application, where, if I launch a thread,
and then close the web page, when I open the webform again, I could see
a result?

Nov 16 '05 #1
5 1336
The short answer to your first question is that closing the client browser
window will not end the thread.

And to the second question, no, there is no way to open a new browser window
and see the result directly.

What you can do is store an identifying value in a cookie and the result of
your thread operation in some persistent format such as a database. Then,
when the new browser opens, you could identify the user by the cookie and
retrieve the value to provide that user from the database.

Semi-permanent storage such as Application variables will not work because
you can't be sure that the same process will still be running or will handle
the new request.

Here's an article to introduce you to threading in ASP.Net applications:

http://msdn.microsoft.com/library/de...forWC-CH01.asp

HTH

DalePres
MCAD, MCDBA, MCSE
"Jensen Carpenter, Mortician" <jc********@national.death.agency.us> wrote in
message news:1110585063.52e7972fa2beda973eb89a4261f84970@t eranews...

If I put a ThreadStart on a ThreadPool, triggered by a button on a web
form, and I close the web form -- will the method on the Thread run to
completion?

Is it possible to build a web application, where, if I launch a thread,
and then close the web page, when I open the webform again, I could see a
result?

Nov 16 '05 #2
DalePres wrote:
The short answer to your first question is that closing the client browser
window will not end the thread.
Great...so even if it's a long running process...and I put it on a
ThreadPool with no return value...it will complete...how about if it
does return a value...will it complete?

Can I see this in VS.NET 2003?
And to the second question, no, there is no way to open a new browser window
and see the result directly.
That's okay too. I will return a status to a database from the thread,
and then refresh the web form ( or it will just update the datagrid when
they log back in ).


What you can do is store an identifying value in a cookie and the result of
your thread operation in some persistent format such as a database. Then,
when the new browser opens, you could identify the user by the cookie and
retrieve the value to provide that user from the database.

Semi-permanent storage such as Application variables will not work because
you can't be sure that the same process will still be running or will handle
the new request.

Here's an article to introduce you to threading in ASP.Net applications:

http://msdn.microsoft.com/library/de...forWC-CH01.asp

HTH

DalePres
MCAD, MCDBA, MCSE
"Jensen Carpenter, Mortician" <jc********@national.death.agency.us> wrote in
message news:1110585063.52e7972fa2beda973eb89a4261f84970@t eranews...
If I put a ThreadStart on a ThreadPool, triggered by a button on a web
form, and I close the web form -- will the method on the Thread run to
completion?

Is it possible to build a web application, where, if I launch a thread,
and then close the web page, when I open the webform again, I could see a
result?


Nov 16 '05 #3
in
DalePres wrote:
The short answer to your first question is that closing the client browser
window will not end the thread.


In VS.NET it looks like the threads end when I press stop.

Shouldn't they continue on ?

Are you sure they continue...
Nov 16 '05 #4
I don't think the web server has any knowledge of the client browser
pressing stop. However, I could be wrong.

It is an easy test though - just output some message into a file at the end
of the request and put a Thread.Sleep(1500) in there. That will cause it to
wait 1.5 seconds until it finishes - giving you time to hit stop. Then
check and see if the debug message was written.

Take care.

--
Nathan

"in" <gu*****@treeview.control> wrote in message
news:42**************@treeview.control...
DalePres wrote:
The short answer to your first question is that closing the client
browser window will not end the thread.


In VS.NET it looks like the threads end when I press stop.

Shouldn't they continue on ?

Are you sure they continue...

Nov 16 '05 #5
Yes, they end when you close down the browser in Visual Studio. But that is
simply slide of hand because closing the browser causes the debugger to
detach from the running process and unload the application domain. That
certainly does not happen in the real world. Visual studio plays certain
tricks. In the real world, the server knows nothing about the front end. It
receives a request, handles it, and disconnects. It could care less if the
requestor never showed up again - the web is stateless.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
"in" <gu*****@treeview.control> wrote in message
news:42**************@treeview.control...
DalePres wrote:
The short answer to your first question is that closing the client
browser window will not end the thread.


In VS.NET it looks like the threads end when I press stop.

Shouldn't they continue on ?

Are you sure they continue...

Nov 16 '05 #6

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
22
by: Jorge Godoy | last post by:
Hi! I must have been searching in the wrong places or with the wrong keywords but I couldn't find out how to implement something such as what is done by the threading module on Windows (95, 98...
4
by: Jose | last post by:
after searching on amazon, i found no good books on threading in ..net/C#. does anyone know if any are in the works? I've seen lots of questionable threading code in our C# environment, and...
8
by: Yatharth | last post by:
Hi, I m new to threading and i have successfully runed threading but i could display value on my web page ,but its working in code behind when i see it through debugger,plzzzzzzz help me here...
15
by: WXS | last post by:
When I see things in .NET 2.0 like obsoletion of suspend/resume because of the public reason MS gives of they think people are using them inappropriately.. use mutex, monitor and other...
6
by: Fred Exley | last post by:
Just trying to understand the basics here. If the OS has just one CPU, what advantage is there in threading? thanks
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
0
by: smimon | last post by:
Hi I'm trying to run a DTS package from a ASP.NET web page using System.Diagnostics.Process. This DTS takes up to 10 minutes to complete, during which, output is generated which i would like to...
24
by: Maric Michaud | last post by:
This is a recurrent problem I encounter when I try to sell python solutions to my customers. I'm aware that this problem is sometimes overlooked, but here is the market's law. I've heard of a...
4
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.