Adding a delay in the application (for debugging)

I would like to add a delay between the two lines of code because I am testing the updateprogress template. Ideally single line.

Thank.

+3
source share
7 answers

Try Sleep . Example:

Thread.Sleep(3000); //3 seconds

You will need to add this using the directive:

using System.Threading;

to access the method.

The parameter you pass is the number of milliseconds you want to pause the current thread.

+9
source

Are you looking for Thread.Sleep (2000)?

+1
source

Thread.Sleep :

#if DEBUG
    Thread.Sleep(1000);
#endif
+1

, Thread.Sleep.

Thread.Sleep(10000);//Waits 10 seconds.
0
0

You can put this line in a condition that will only be "true" by passing this amount of time using the delay method: Thread.Sleep (time)

0
source
System.Threading.Thread.Sleep(int time_ms); //One line, no 'using' :)
0
source

Source: https://habr.com/ru/post/1791020/


All Articles