Conceptual Problem

  • Thread starter Thread starter Martin Payne
  • Start date Start date
M

Martin Payne

Say I want to write a page that, when delivered, displays
a button labelled 'start'. When the button is pressed, a
process is initiated server-side that, say, writes random
values to a database table every second. And, at the
same time, the page no longer displays a start button but
begins displaying the contents of the database table,
refreshing every 5 seconds.

I have two questions. Firstly, how would I get an aspx
page to kick off a process and return a page before that
process is finished (the process will continue running in
the background). I've already figured how to stop the
process when needed (I just set a flag somewhere that the
process checks on each iteration, when I want the process
to stop I change the flag), I just can't figure how to
start the process and deliver a new page without waiting
for the proess to complete.

And, secondly, how do I get the page that displays the
table contents to refresh every 5 seconds?

Thanks
Martin
 
Martin Payne said:
Say I want to write a page that, when delivered, displays
a button labelled 'start'. When the button is pressed, a
process is initiated server-side that, say, writes random
values to a database table every second.

And, at the
same time, the page no longer displays a start button but
begins displaying the contents of the database table,
refreshing every 5 seconds.



I have two questions. Firstly, how would I get an aspx
page to kick off a process and return a page before that
process is finished (the process will continue running in
the background). I've already figured how to stop the
process when needed (I just set a flag somewhere that the
process checks on each iteration, when I want the process
to stop I change the flag), I just can't figure how to
start the process and deliver a new page without waiting
for the proess to complete.

I would problably do it this way:
when the page loads , in the Page_Load event, check for a flag that
switches to true with the button is pressed, and do the random DB
process in a simple loop. Use the clock to check for seconds and do it
just 5 times (5 seconds). After that, reload the page.

This way, during postback the process will not continue however. If
that is what you really want you might want and try to find out more
about threads. But I don't think it will be easy to safely implement
it.

Freek Versteijn
 
Back
Top