I've got a non-GUI class that generates events as to what it is doing (which are in turn used by a Form to display to the user the progress).
One of the events is a AboutToDoSomethingDestructiveEvent
. Now we want to have the Form display a dialog to the user when AboutToDoSomethingDestructiveEvent
is raised, asking them if they would like SomethingDestructive
to happen. If they select no, then we would set a value on the customer EventArgs
and the original form would read that value and then skip doing SomethingDestructive
.
Is this a proper use of Events and EventArgs
? Are there problems with this approach? Are there any best practices for doing this sort of thing?
The approach is so good there's even a class in the .NET Framework for this: CancelEventArgs