Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Infintite for loop prob

Infintite for loop prob

Scheduled Pinned Locked Moved ASP.NET
performancehelptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alimohammed
    wrote on last edited by
    #1

    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

    M T 2 Replies Last reply
    0
    • A alimohammed

      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

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      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)

      A 1 Reply Last reply
      0
      • A alimohammed

        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

        T Offline
        T Offline
        Tristan Rhodes
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • M Marcus J Smith

          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)

          A Offline
          A Offline
          alimohammed
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • T Tristan Rhodes

            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.

            A Offline
            A Offline
            alimohammed
            wrote on last edited by
            #5

            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

            T 1 Reply Last reply
            0
            • A alimohammed

              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

              T Offline
              T Offline
              Tristan Rhodes
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups