Skip to content

Instantly share code, notes, and snippets.

@posaunehm
Last active December 11, 2015 21:18
Show Gist options
  • Select an option

  • Save posaunehm/4661427 to your computer and use it in GitHub Desktop.

Select an option

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)
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