Last active
December 11, 2015 21:18
-
-
Save posaunehm/4661427 to your computer and use it in GitHub Desktop.
Show winform dialog with timeout (as extension method)
Maybe useful for test code (ex: UI smoke test)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void ShowDialog(this Form dlg, int timeout) | |
| { | |
| dlg.Shown += (sender, args) => Task.Factory.StartNew( | |
| () => Thread.Sleep(timeout)).ContinueWith( | |
| _ => dlg.Close(),TaskScheduler.FromCurrentSynchronizationContext()); | |
| dlg.ShowDialog(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment