Multithreading and Sessions

I

Imran

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
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top