How to make the Click event of a Button to deal with an asynchronous remote service

H

Henrik Dahl

Issue:

I have a remote service executing notoriously asynchronously which I must be
able to use from my Compute_Click(...) event handler. The WebForm I have
contains only two controls: A Compute button and a Result textbox. I may
easily start the asynchronous execution in the Compute_Click event handler.
The asynchronous service notifies me when it's result is ready, the
notification is done by a delegate invoking ResultReady(...). My problem is,
that ASP.NET sends the page back to the client as soon as the last line in
Compute_Click() has been executed, but actually I would like to make the
page go to the server after the last line of ResultReady() instead. So my
question is, how to tell ASP.NET that the page is not ready after the last
line in Compute_Click() but ready after the last line of ResultReady()?


Best regards,

Henrik Dahl
 
N

Natty Gur

Hi,

You can create Class that handles all of that work for you. Your class
implements public function that you will call from your page, two
private functions and private inner state member. One private function
starts async call and the second receive the async callback. Receiving
async call function will change private state member when data arrived.
Class public function call the first function and wait until inner class
state member changed or certain timeout interval elapse.

If your async work extends the default web call timeout you should
consider other solution …

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-8883777
 

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

Top