delay function in vb2010,delay in vb 2010,delay in visual studio,how to add delay in vb, vb 2010 delay function
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.
For example, in some project you want to turn on two lights one after another with a delay of like 5 sec so now what will you do. You will first turn the first light on and then add a delay of 5 sec and then turn the second light on. That delay just let your code wait for 5 sec and then execute the next line. So, now we have an idea what is a delay so lets have a look at how can we add this delay in visual studio 2010.

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 need to calculate this value for your required delay and add it here. Note:
  • 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.
As I told earlier, its quite a small tutorial, in fact not a tutorial just a quick trick of adding a delay in visual studio 2010. If you are interested in Visual studio projects then must read How to send Emails in Microsoft Visual Studio 2010. Its quite exciting. :)