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

Multithreading and Sessions

I have an asp.net application that uses multithreading to allow for progress
bar aproach while its doing its work in the backgroung in the secondary
thread. the main thread is just refreshing the page while the backgroung
secondry thread is doing the actual processing. When my secondary thread is
finished, i like to save a dataset to the session object ( i am using SQL
server basesed persistance ) so that my main thread can access it. Problem
is that my seconday thread is not running in the page request context
because "httpcontext.current.session" is not valid when i try to access it
in my secondry thread routine.

So, i get an error like "session state is not enabled". How do i spawn
thread which is aware of its context objects when done ?

Any help is greatly appreciated.

Imran
Nov 18 '05 #1
1 1577
you have a couple issuse.

1) you need pass the session object to the thread.
2) you will need sync saving with the page thread, as it will do a session
save at the end of page processing
3) your background will need to call the session api to save the session
changes
4) you background thread runs in the security context of the asp_net
application, not the thread that creates it, so it needs to set its secuirty
context it self.

you migh need to supply you own sesson module to get this to work. it would
be eaiser to just create another table in the session database to store your
object (or even you the session table) , and only store the key in the
session. (you still need to tackle #4)

-- bruce (sqlwork.com)

"Imran" <im*********@hotmail.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
I have an asp.net application that uses multithreading to allow for progress bar aproach while its doing its work in the backgroung in the secondary
thread. the main thread is just refreshing the page while the backgroung
secondry thread is doing the actual processing. When my secondary thread is finished, i like to save a dataset to the session object ( i am using SQL
server basesed persistance ) so that my main thread can access it. Problem is that my seconday thread is not running in the page request context
because "httpcontext.current.session" is not valid when i try to access it
in my secondry thread routine.

So, i get an error like "session state is not enabled". How do i spawn
thread which is aware of its context objects when done ?

Any help is greatly appreciated.

Imran

Nov 18 '05 #2

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

Similar topics

47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
3
by: Ken Brannigan | last post by:
Hello, I am a little confused regarding the creation of a C# DLL that will be called from ASP.NET. From what I have read ASP.NET is Multithreaded. My undersatnding of this is that more than one...
5
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
28
by: JV | last post by:
My ASP.NET application needs to accept data from a post and return quickly. I've added a worker thread to wake up and save data asynchronously after the data is received. But, it appears to me...
5
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.