|
Rank: Newbie Groups: Member
Joined: 10/8/2010 Posts: 2
|
Hi, I have a developer's license for your (2010) suite and I am using your ProgressBar & CallbackPanel in a manner very similar to the 'Server Side Task - Advanced 2' demo and everything works great except for one thing:
If the user cancels the process (vs the process ending normally), I need something to happen besides just stopping the ProgressBar. The User needs to be informed that the process was indeed canceled. The process I am performing is very lengthy and the progress will be very slow, so when the user clicks the cancel button, they could be waiting for quite some time before they can confirm that the progress was indeed canceled.
When the process completes, the application continues with the next task(s) as it should, the only problem I am having is I need to perform some task (client side or server side) automatically upon cancelling the process.
Can you please let me know how I might accomplish this?
Thanks, Tim Sygitowicz
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
When user cancels the progress bar, the IsStopped property of the ProgressBarTaskEventArgs is updated to true. So you will need to check that periodically in order to properly cancel your task. Note that you must poll this value. There is no event callback mechanism for canceling a progress bar.
There is no built-in way for you to automatically perform some tasks after the progress bar is canceled. One possible solution is to use your own Cancel button, then write code to call the progressBar's stopTask inside that button's click handler to stop the progress bar. After calling the progressBar's stopTask, you can then call some additional code to perform your additional task. However please keep in mind:
1. You can not do a post back/redirect immediately after calling stopTask. This is because internally stopTask does a post back in order to notify the server that the task has been requested to stop. Posting back or redirecting would unload the hosting page thus affect that post back. If you need to do a post back/redirect, you can delay the call with a timer so that the progress bar post back will have enough time to complete;
2. Calling stopTask merely send out a notification to the server "requesting" the task to stop. Whether your server side code checks for this (by checking IsStopped property) and actually stops your task is a different thing. As such you can not assume that your task has already been stopped after stopTask has been called;
Hope this helps.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/8/2010 Posts: 2
|
Thank you. Your answer was exactly what I needed to know. Works great now, thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Great. Please feel free to let us know if there is anything else.
Thanks!
|
|