February 14, 2012
Executing Actions Before and After Code Blocks with IDisposable
I ran into a scenario this week where a boolean field was being flipped temporarily to modify behavior elsewhere while a block of code was executing. I have seen this pattern mainly in WinForms applications where data are being loaded into controls, but their events need to be suppressed during the load. Afterward, the events should fire normally.
Below is an example of this scenario. It is a Windows form with a single combobox.
Read more