Infintite for loop prob
-
Hi all, I use an infinite for loop in my code to do some tasks and use thread.sleep to wait for some time and restart the loop again. for(;;) { // do something. thread.sleep(time); } i use around 5 hrs for the sleep and it works fine for two or three days, but after that i get an exception "thread aborted". i think that its because of memory problem. Any idea how to catch up this prob? thanks in advance. Ali
-
Hi all, I use an infinite for loop in my code to do some tasks and use thread.sleep to wait for some time and restart the loop again. for(;;) { // do something. thread.sleep(time); } i use around 5 hrs for the sleep and it works fine for two or three days, but after that i get an exception "thread aborted". i think that its because of memory problem. Any idea how to catch up this prob? thanks in advance. Ali
Wow, why are you using an infinite loop on purpose? What are you trying to do, maybe we can suggest an alternative for you.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
"Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School) -
Hi all, I use an infinite for loop in my code to do some tasks and use thread.sleep to wait for some time and restart the loop again. for(;;) { // do something. thread.sleep(time); } i use around 5 hrs for the sleep and it works fine for two or three days, but after that i get an exception "thread aborted". i think that its because of memory problem. Any idea how to catch up this prob? thanks in advance. Ali
An infinite loop is generaly for some core process that happens continuously until an exit condition is reached, with maybe a few millisecond sleep.
do { //Logic } while(!ExitCondition)
Try looking at the System.Threading.Timer class for things that have a large time lapse in between invocations. In addition, a ThreadAbort exception indicates that another process closed the thread, and the Abort is raised. You might what to check what has a handle to the thread, and could possibly close it. Tris------------------------------- Carrier Bags - 21st Century Tumbleweed.
-
Wow, why are you using an infinite loop on purpose? What are you trying to do, maybe we can suggest an alternative for you.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
"Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)i actually wanna run a cron job, and i wrote a windows service for this, and used a timer and set the time. but what happens is that, i have written a code to mail an indication to my email id for each start up of the execution, and after that i do some database operations and mailing services. but the database operations work out only when i start the service, and dont work out in each execution [ after timer time is elapsed ], the only mailing service is working out [ i get indication on each 5 hrs and all other users get their emails ]. any idea? thanks, ali
-
An infinite loop is generaly for some core process that happens continuously until an exit condition is reached, with maybe a few millisecond sleep.
do { //Logic } while(!ExitCondition)
Try looking at the System.Threading.Timer class for things that have a large time lapse in between invocations. In addition, a ThreadAbort exception indicates that another process closed the thread, and the Abort is raised. You might what to check what has a handle to the thread, and could possibly close it. Tris------------------------------- Carrier Bags - 21st Century Tumbleweed.
i actually wanna run a cron job, and i wrote a windows service for this, and used a timer and set the time. but what happens is that, i have written a code to mail an indication to my email id for each start up of the execution, and after that i do some database operations and mailing services. but the database operations work out only when i start the service, and dont work out in each execution [ after timer time is elapsed ], the only mailing service is working out [ i get indication on each 5 hrs and all other users get their emails ]. any idea? thanks, ali
-
i actually wanna run a cron job, and i wrote a windows service for this, and used a timer and set the time. but what happens is that, i have written a code to mail an indication to my email id for each start up of the execution, and after that i do some database operations and mailing services. but the database operations work out only when i start the service, and dont work out in each execution [ after timer time is elapsed ], the only mailing service is working out [ i get indication on each 5 hrs and all other users get their emails ]. any idea? thanks, ali
The only thing i can suggest is to add some tracing around the DB logic part and see what it is doing. There is no reason that a DB Query should not work on an event. T
------------------------------- Carrier Bags - 21st Century Tumbleweed.