VB.Net Threading Tasks and Session Life

I have what is hopefully just a simple informational question on VB.Net and Threading.

I have an internal site that has a few tasks that have to be run by users but that are longer running. I do not want the user to be sitting watching their progress spinning for sometimes 10 minutes or longer. I have used threading to separate a couple of these tasks and that is all working. My question is what happens if a user starts one of these and then closes their browser? Does the thread continue on the server until it completes? I eventually want to create a separate .aspx that will monitor a status file on SQL Server. The threads created will update that status file and the monitor program will report their completion. But if the user closing their browser kills the thread, this will not be satisfactory...is there a better way?

thanks,
Scot
Scot SunnergrenCTOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Does the thread continue on the server until it completes?
Since the thread is running on the server, closing the client (a.k.a. the browser) has no bearing on the lifetime of the thread. The answer to your question is no, the thread will not be terminated by a close of the browser.
0
unknown_routineCommented:
When someone closes the browser, the session does not literally expire for a default time of around 20 minutes. When session expires, the OnEnd event fires up. You can write code against this in the global.asax file.


Note  that if your web site


Here it takes 30 minutes...

<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="30" />
  </system.web>
</configuration>

Open in new window

0
Scot SunnergrenCTOAuthor Commented:
Just to clarify...

The session expiration and the OnEnd event will not affect any thread created by that session unless I write code to handle it? The thread will continue despite those if I ignore them in the threaded code? What happens to session variables? I know that they are shared between the the user session and the threads created by that session. Are they cleared when the session ends?

I am currently using them in the threaded code to report back to the user but will probably do away with them if I move to the separate monitoring page.

thanks.
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

käµfm³d 👽Commented:
I believe the only thing that will terminate the thread is the unloading of the App Domain, but I am struggling to locate some documentation to support this claim. In typical .NET, that is what would happen. In ASP.NET, an App Domain is not unloaded until the application has been idle for a period of time (as in no requests came in since XXXX), or if the App Pool is recycled.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
unknown_routineCommented:
I believe the only thing that will terminate the thread is the unloading of the App Domain

100% correct. When App Domain is unloaded, all sessions will end too.
0
unknown_routineCommented:
@ kaufmed:  I see you are only 1.1 million points from the Legend status. Do we have a legend in EE yet?
0
Scot SunnergrenCTOAuthor Commented:
Thank you gentlemen. I will mark accepted but if you have any comment on the effect on the session variables within the started thread, it would be appreciated. Are they cleared or replicated to the thread, retaining their settings...

Thanks for the quick responses!
0
käµfm³d 👽Commented:
@ScotSunnergren

There wouldn't be any duplication of the Session. I believe, though, that you will have to pass a reference to your session to the thread. In reading, I don't see that threads can access the Session object without it being passed to them.

@unknown_routine

I'm actually about 91,000,000 points away from attaining "Legend" status. The closest person to date is angelIII.

http://www.experts-exchange.com/community/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.