Hello friends, hope you all are enjoying good health and having good time. Today's tutorial is not too big and is simple about how to add a delay in visual studio 2010. Before starting this tutorial, let me first tell you that I got an excellent feedback about the last tutorial on How To Use Proteus ISIS & ARES & also got few queries and suggestions. One of them was to post a similar tutorial on the Eagle software as well which I will hopefully start in the coming week.
Today's post is a very small trick but yet very effective one. In a recent project of mine, it helped me a lot and yet its quite a small thing but it took me around half an hour to find it online and that's the reason I decided to share it with you guys. I have to design a software in which I was using a database in visual studio 2010 and in that project I have to add some delay in my readings addition in database so I was like :O how to add delay in visual studio 2010. I searched online and after quite a lot of time I finally able to get it, which I am sharing now in this post. Btw if you wanna learn about database then read How to create a database in visual studio 2010. After the creation of any software in visual studio there's a need of creating its executable file so that we can use the software standalone and just simply install our software on any computer so I think you should also read How to create exe file in Visual Studio 2010. Anyways coming back to adding delay in visual studio 2010, let's first discuss delay in programming language. :)
What is a delay?
The engineers who had worked on Microcontrollers like Arduino or PIC Microcontroller or 8051 Microcontroller, then they know that what is a delay.- A delay in programming is a statement which adds a pause in your code.
Add a Delay in Visual Studio 2010
In Microsoft Visual Studio, the command used for adding the delay is:System.Threading.Thread.Sleep(1000)This command will generate a delay of 1sec. You can change this value in order to change the time of delay. i.e.
- 500 for 0.5 sec delay.
- 2000 for 2 sec delay.
- 5000 for 5 sec delay.
- You should take much care in using this delay because this delay simply makes your software to sleep and thus while the delay is in process, your software won't do any other task.