Try to break while-loop after some time

Hey all together.

This is my first post, so i hope you can help me a lot :). English is not my first language.

I got a while-loop and a time how long it should run, but sometimes it needs too long. In the while-loop i got a function call: runSimulation(). I followed the error 'till i saw, that a function from eclipse-prolog needs too long.

I tried to break the function, when i just got 2 seconds left, but it needs sometimes 6 seconds but i just got 5 for the whole simulation.

Now I want to know: Is there an opportunity to get a timecontrol into or around this while-loop to break it off, when the timelimit is reach?

Thanks in advance,

Eldastoker
Last edited on
You can get system time before you enter the while loop and test for time elapsed inside the while loop when it is time you break, gettimeofday(), setitimer() or time()
Topic archived. No new replies allowed.