What would be a clever way to make a 'please wait' control for a Flex application for long running operations like calling a webservice.
I am not asking about the graphical portion of it – just the 'controller' part. How should I trigger it and hide it. I am planning to make just a simple canvas with text in.
For instance :
- can I somehow intercept all web service calls – and not have to activate it for every web service
- how should i add it to my canvas. should it be added to 'stage' as a top level component?
- should it have a 'cancel' button to cancel the web service request if it takes too long. that sounds kind of complicated because I'm not even sure if I can terminate a running async web request?
FYI: This is for a reporting application so long running queries are to be expected
Best Answer
One way I have done it in the past is to have a global integer and increment / decrement the value based on the web services running. When the counter was 0, I would hide the loading text, when it was greater than 0, I would display the loading text. Here is a simplified version of it:
I then had a little helper class to control the global counter:
Then all that needs to be done is to call the helper function when a web service is called...e.g:
I always have thought there was a better way to do this, like you said have some type of hook to detect if a service is running...I'm looking forward to other responses in this post...