Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software getting info from my threads

I have an import routine that chomps through about 200k records and imports them into the database. Here is how it happens: (all through a browser interface)

1) user uploads file with ~200k records
2) user sees preview of records uploaded
3) user clicks "start import"
4) user is redirected to a status page (records imported so-far, running time, etc..)

Now my problem. The actual work is being done by a thread in a component that the web application passes the records to. My question is "how do I get info from that thread?" Right now I just have the thread update a status table in the database then I read from it, but there has to be a more "correct" method of receiving messages from, or somehow polling the thread for the information. I have tried using httpcontext.current.session to communicate, I have tried moving the threading logic into the  code-behind aspx.vb portion of code. Nothing I can come up with works. In the past all my threads have just gone off and done thier job (send email, etc) then died. This is the first time I have needed status from them. Can someone point me in the right direction?

thanks in advance,

Roger Altace
Wednesday, July 21, 2004

jegan jegan jegan

Thursday, July 22, 2004

What's wrong with using a status table? Sounds like you already have a good solution.

Thursday, July 22, 2004

Try creating a singleton and using that as your storage.
for example,
1. create a hashtable in the singleton initialisation
2. Get the page that starts the thread to generate a unique key (ie GUID) use that as the key for the hashtable.  Return the key as a querystring to the status page
3.  As the worker thread is chomping thru the records, update the hashtable using the previously generated key
4. The status page queries the singleton using the key to get the progress.
5.  When the worker thread finishes, either remove the entry from the hashtable, or mark it as completed.

Robert slaney
Tuesday, July 27, 2004

*  Recent Topics

*  Fog Creek Home