My ChildWindow
has CloseButton and handler assigned to Click
event. Code (only for example):
Declaring close button:
<Button x:Name="CloseButton" Click="OnCloseButtonClick" />
Private counter (for diagnostics problem):
private uint _i;
Close event handler:
OnCloseButtonClick(object sender, RoutedEventArgs e)
{
DialogResult = true;
System.Diagnostics.Debug(_i++);
}
After fast clicking program can output "1", "2", "3", and so on...
As i know after setting DialogResult
= true
(or false
), ChildWindow should be closed and there should not be any way to raise the CloseButton's Click
event second time.
Can anyone help me to figure out cause of the problem and help to solve it without bool flags (executed/!executed)?