0

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);
        goto 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.

4

1 回答 1

2

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.

于 2010-06-10T10:02:10.857 回答