So, something's been bugging me about the new async support in C# 5:
The user presses a button which starts an async operation. The call returns immediately and the message pump starts running again - that's the whole point.
So the user can press the button again - causing re-entrancy. What if this is a problem?
In the demos I've seen, they disable the button before the
await call and enable it again afterwards. This seems to me like a very fragile solution in a real-world app.
Should we code some sort of state machine that specifies which controls must be disabled for a given set of running operations? Or is there a better way?
I'm tempted to just show a modal dialog for the duration of the operation, but this feels a bit like using a sledgehammer.
Anyone got any bright ideas, please?
I think disabling the controls that shouldn't be used while an operation is running is fragile because I think it will quickly become complex when you have a window with many controls on it. I like to keep things simple because it reduces the chance of bugs, both during the initial coding and the subsequent maintenance.
What if there is a collection of controls that should be disabled for a particular operation? And what if multiple operations are running concurrently?