Hello friends,

I had done some questions regarding function call.

I had done an console application that can run a particular set of code every minute.

For that i used

System.Threading.Thread.Sleep(60000);

That worked well too.

But now i stuck in another problem.

Now I dont wanna use the above code.Because of the reason the thread.sleep() makes the entire application to sleep for a minute. But I am having a code that must be executed in the mean time.

Any suggestions or help?

TIA...

@Ketsuekiame,

Fine. But I can use it as an last resource.

because i am new to console application.

I am having little doubts regarding basics of c#.

Before that, let me explain you a scenario.

My code will be like

void main()
{

DateTime a=DateTime.Now;
DateTime b=DateTime.Now.AddMinutes(1);
//

Codes that needs to be executed all the time.


//

int Difference = (b - a).Minutes;
if(timedifference=1)
{

//    

call function i.e., code that has to be executed for every minute

//
}
}

The above is my coding procedure which i have planed so far.My doubt is that
1)whether the condition is checked frequently or only once?
2)if the entire code is executed again and again does the datetime values are initiated every time?

The questions may be childish... But I am noob when it comes for console app..

Well.. the condition is checked frequently...

IF the condition is checked frequently, then the decalration will also be done frequently...

Your condition is checked only once when you start the application. You'd need a while loop. However, the Timers are built specifically to do this kind of work and they'r every easy to implement.

Fine... That leaves me without option :-). I will try and intimate you guys shortly...

Thanks for your response.

This article has been dead for over six months. Start a new discussion instead.