views:

78

answers:

0

This is the scenario. I am using scsf to develop my application. I am using asynchronous delegates to keep my UI responsible. I have a CAB service which is in charge of notifying exceptions to the final users in a friendly manner (message box).

I will show you an hypothetical example which ilustrates the actual issue (I will reduce the use of SCSF jargon so non SCSF developers can follow the issue): A final view (User Control, "container") is a composition of two other views. Every view load data while its loading. The amount of data every view try to retrieve is huge. That is another reason to use asynchronous delegates and keeping UI responsible. But what happens if an error ocurred! The exception is handled by each subview and two messageBoxes are shown to the user with a friendly exception message (one messageBox per view). This custom message box also allows the final user to retry (in case of network failures). But, wait again, what if the user decide to cancel the action! My requirement is to close the container view and close the interaction. Problem is two messageBoxes are being displayed. Because these messageBoxes are always on a different thread, I placed a lock on the notification CAB service method in charge of displaying the messageBox, with this the next messageBox has to wait for the actual messageBox finishes its interaction, after this the next messageBox will be displayed. (The translation of this is user will never see two messageBoxes at the same time, this is the desirable behavior). Anyway, if the user hit cancel on the actual messageBox the container view is closed but the next messageBox which was waiting for the lock to be released appears immediately. This is the normal flow and it occurs as I expected. However, I need to prevent this from happening. Second messageBox should not appear: because that interaction was already discarded by the user when she clicked cancel.

Have you handled an scenario like this before. Any help or idea would be appreciated.