| 181 | } |
| 182 | |
| 183 | private void OnClosing(ClosingReason reason, ref bool cancel) |
| 184 | { |
| 185 | // Check if can close window |
| 186 | if (CanCloseWindow(reason)) |
| 187 | { |
| 188 | if (reason == ClosingReason.User) |
| 189 | _result = DialogResult.Cancel; |
| 190 | |
| 191 | // Clean up |
| 192 | _window = null; |
| 193 | |
| 194 | // Check if any thread is blocked during ShowDialog, then wait for it |
| 195 | bool wait = true; |
| 196 | while (wait) |
| 197 | { |
| 198 | wait = Interlocked.Read(ref _isWaitingForDialog) > 0; |
| 199 | Thread.Sleep(1); |
| 200 | } |
| 201 | |
| 202 | // Close window |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | // Suppress closing |
| 207 | cancel = true; |
| 208 | } |
| 209 | |
| 210 | private void OnClosed() |
| 211 | { |