Vb.Net waiting for process 30secs
I have three events to fire on bu开发者_运维百科tton click.
after running the first event i want to wait for 30sec to wait for nex event to fire.
how i can wait( i mean looping for 30 secs).
Thanks, Nag
You can try this to your code directly:
MessageBox.Show("Test") ' Execute your method 1
System.Threading.Thread.Sleep(30000)
MessageBox.Show("Test2") ' Proceed with the other one :)
If you wait on the UI thread you'll block the whole UI and Windows will show your application as non-responding.
Better to:
- Update the UI to show it is busy, including disabling controls to block user input.
- Use a timer control (details depend on WinForms or WPF) to trigger an event after the time delay
- Do the work in the timer's event handler.
If the work is CPU or IO intensive (ie. likely to block for more than a few tens of milliseconds) then perform the work in the threadpool (eg. BackgroundWorker
component). Remember you'll need to use Control.Invoke to make any changes to the UI from the worker thread.
You can use Thread System.Threading.Thread.Sleep(30000);
to hold execution.
use a timer for it and set an interval of 30 seconds to timer (1sec = 1000)
timer1.Interval=30000
精彩评论