I'm trying to write something to stop running the code after 15 seconds of running.
I don't want While
loop or any kind of loop to be used and would like to use IF-ELSE conditions instead as it would make it easier for me in my code.
The part of code I want to stop being executed after 15 seconds is a FOR loop itself. Let's consider the below code for example:
for (int i = 1; i < 100000; i++)
{
Console.WriteLine("This is test no. "+ i+ "
");
}
How would you stop this loop after 15 seconds of running?
See Question&Answers more detail:os