Simple program logic to Call method continuously
I am in a situation, in which my program needs to do processing and then wait for some interval, let's say 5 seconds and the do the same processing again.
I don't know how to implement the logic.
I have developed a logic, the code is below:
private void ProcessEmail()
{
PprocessEmail:;
//Do whatever you want
System.Threading.Thread.Sleep(5000);
got开发者_JAVA技巧o ProcessEmail;
}
What this code does: I only have to call this method once, it will do the processing then wait for 5 seconds and then again process.
So far above code is working fine, but i have heard using "goto" statements is not considered good in programming.
I want to know, will there be any side effect of this code or is there any other efficient way of doing the same thing.
Look at loops. This Wiki article might be a good place to start for the theory.
If it's C#, what you'd use is a while(true)
that would loop forever.
精彩评论