background thread after page is being rendered

N

NIan

recently I have to create a search engine that will pick up stuff form
different external source. they will be divided into sections(tabs). My
idea is:
1. Multithread (Default Tab content with Highest Priority, rest with
low)
2. Once the default tab is done it will render the page
2. On the background:It will get the rest of the data and put into
session variable
3. When user click on different section (PostBack). it will check the
SESSION variable if the data is ready.
4. If it does ... perform the databinding process.

my problem is after the page is being render and display to the client.
and from debug mode it went though the process of adding to data to the
SESSION variable. but when User click on different section the SESSION
variable remain the same.
 
B

Bruce Barker

the background thread will not have access to the session object (because
the Session object only lives the life of the page). if you are using the
inproc session manager, you could pass the object to the thread, and add it
to session.

-- bruce (sqlwork.com)
 
N

NIan

by default asp.net uses inproc session manager, so that's good to go
but pass the object to the thread, can you explain? because I'm still
in ASP.NET 1.1 can't pass any paramete
if (!Page.IsPostBack)
{
ThreadStart TS = new ThreadStart(RunThreadA);
Thread ThreadA = new Thread(TS);
ThreadA.Name="ThreadA";
ThreadA.IsBackground = true;
ThreadA.Start();
ThreadStart TZ = new ThreadStart(RunThreadB);
Thread ThreadB = new Thread(TZ);
ThreadB.Start();
ThreadB.Join();
}

public void RunThreadA()
{
......Business logic....
lock(Session.SyncRoot)
{
Session["FinishedThreadA"] = true;
}
}
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top