I want to make the user wait for 5 seconds before the user can do something but I'm having trouble as I don't want to do Thread.Sleep(5000); as I want the form to be loaded and the functionality to be be viewable but I don't want to allow the user to do anything for those 5 seconds (well they can attempt to click buttons but nothing should happen).
What I did to make this work (my code is slightly different due to properties) thanks to the answerer:
var t = Task.Delay(1000) //1 second/1000 ms
t.Wait();
Well you can always disable all form and after 5 seconds enable it...
(example using .net framework 4.5)
//Your window Constructor
public MyWindow()
{
InitializeComponent();
this.Cursor = Cursors.WaitCursor;
this.Enabled = false;
WaitSomeTime();
//load stuff
.....
}
public async void WaitSomeTime()
{
await Task.Delay(5000);
this.Enabled = true;
this.Cursor = Cursors.Default;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With