aspx page to kick off async background task and then end

C

Carl Johansen

I'm not sure of the best way to do what I want. Users of my website want to
run reports that take a long time to generate. This is what I would like to
happen:

1. User requests aspx page
2. aspx page kicks off an asynchronous background task (on the same web
server) to generate the report. The end result will be a file created on
the website.
3. aspx page returns this message to the user: "your report is being
generated, check back in a few minutes"
4. aspx page ends.
5. (optional, the icing on the cake) A frame in the user's frameset starts
(through client-side script) sending periodic requests to the server to
check whether the report is ready, and displays a message box to inform the
user when they can pick it up.
6. User goes to their "My Reports" page and collects the report
7. After 24 hours the report file is automatically deleted from the server

Now, my question is how to do step 2. I guess it could be done with MSMQ,
but is there a better way? I tried making a Windows service and making an
asynchronous call to it with Delegate.BeginInvoke(). However, it doesn't
seem suited to my situation because it seems to insist that the caller (the
aspx page) stays alive for the end result, whereas I want the caller to
terminate while the callee is still running. When my BeginInvoke() caller
terminates, the callee seems to stop also. Additionally, the documentation
says the caller must call EndInvoke(), which mine can't.

Am I on the right track, or should I be using MSMQ? Shelling? A web
service? Some kind of ThreadPool? So many technologies...

Thanks in advance,
Carl Johansen
http://www.carljohansen.co.uk
 
E

Eliyahu Goldin

Carl,

I don't know much about MSMQ, but I can put my 2c in your Windows service
cashbox.

A Windows service seems to be an appropriate solution in your case. As you
write, all you need to do is to kick a task off. But you are doing it in a
complicated way. There is a much simpler way.

Every time when the user requests a report, make a text file with the
request parameters in a preset location. Equip the windows service with a
FileSystemWatcher object that will notify the service about new request
files. Just in case make the service to poll the request directory
periodically to pickup missed notifications.

When the service is done with a report, it can send a notification email to
the user. If you wish, you can attach the report to the email.

Eliyahu
 
C

Carl Johansen

Tom,

Thanks a lot; the article's idea of creating a custom thread is looking
promising.

Carl.
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top