Results 1 to 12 of 12

Thread: timer and freeze or program not responding program

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    timer and freeze or program not responding program

    I have this program made. It does some work then stops the work, executes the timer to wait for a number interval then work again.

    For some time, the execution is fine but after how many times, the program will stop responding and makes the program hang or freeze.

    What should I do to correct this?

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,429

    Re: timer and freeze or program not responding program

    Quote Originally Posted by codesearcher View Post
    I have this program made. It does some work then stops the work, executes the timer to wait for a number interval then work again.

    For some time, the execution is fine but after how many times, the program will stop responding and makes the program hang or freeze.

    What should I do to correct this?
    Somewhat depends on how you're doing it in the first place... Some examples of what you're doing would help us to give an informed answer.

    Poppa.
    Along with the sunshine there has to be a little rain sometime.

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: timer and freeze or program not responding program

    Not seeing your code = no suggestions.
    The fact that you said it runs OK for a short period of time but will eventually hang if left running for too long may point to resource management issue, that is you don't properly release resources after you're done using them. To help you further, I need to see your code.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,038

    Re: timer and freeze or program not responding program

    When it hangs, hit pause and see where execution stops. It sounds like you might be in a perpetual loop.

    Aside from that, we'd have to see some code as to how you are doing the pausing to be able to say anything more.
    My usual boring signature: Nothing

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: timer and freeze or program not responding program

    It maybe simpler than that... it's possible that your code is sos busy it can't/doesn't respond to UI updates... so it looks locked up, but in fact it's just busy. When you get that "stopped responding" message from Windows, what's happening is that the OS is tapping the application on the shoulder asking if there are updates or if anything is going on. If the process is too busy to respond (could be due to some heavy processing, or some loop that's running real tight) Windows basically says "huh, ok, no response" and reports it accordingly. Like when you call someone and they don't answer... you don't instantly think that they've been kidnapped and are being held ransom... you simply realize they are too busy to answer the phone.

    That said, you should look into what is going on when it appears to be locking up... it might be as simple as moving it to a secondary thread, allowing the main thread where the UI is, to respond to polling requests, and then your app won't have that locked up appearance or the "not responding" error message.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: timer and freeze or program not responding program

    my code is simply like so:

    Code:
    private sub firstfunction()
         do some calculations
         timer1.interval=900000
         timer1.start()
    end sub
    
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
         timer1.stop()
         firstfunction()
    that's just it. I have three forms that uses the same code.

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,038

    Re: timer and freeze or program not responding program

    The forum is acting up a bit today. Lots of duplication happening to people.

    Try pausing when it locks up. Where does it stop? There are two things you could do at that time, one is to press F5 to continue, then pause again, and do this repeatedly to see whether or not the code is just sitting at one place or if it is doing something...perpetually. The other thing you could do is pause and hit F10 to see whether you step forwards. If you are in a perpetual loop, it may be a long one. Looking at the stack trace may help, though it seems unlikely. What it might show is that you are deep in lots of calls, but that would tend to cause a different issue.

    There are several things that could do this, and we don't really know what the answer is, yet. It depends on what is happening in those functions. One thing that I have run into recently is where I was doing something to a database in a transaction, then tried to access something from the DB outside of the transaction. Of course, we don't know if that is even possible, but depending on what you are doing, you could be causing a deadlock like that. Perpetual loops will also cause the behavior, and may be more likely. Pausing and stepping would show this. If you pause and find that the code is just sitting on one line, then you are deadlocked for some reason. If you pause and can step forwards, you are in a perpetual loop.
    My usual boring signature: Nothing

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,764

    Re: timer and freeze or program not responding program

    Quote Originally Posted by codesearcher View Post
    my code is simply like so:

    Code:
    private sub firstfunction()
         do some calculations
         timer1.interval=900000
         timer1.start()
    end sub
    
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
         timer1.stop()
         firstfunction()
    that's just it. I have three forms that uses the same code.
    What makes you think it is hung up? Just wanted to double check that you know that it will be 15 minutes between 'firstfunctions'. Without a better understanding of 'do some calculations' it will be hard to help.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: timer and freeze or program not responding program

    Quote Originally Posted by Shaggy Hiker View Post
    The forum is acting up a bit today. Lots of duplication happening to people.
    There seemed to be a few here at least... I've removed them, and will look out for more (thanks for letting us know )

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,038

    Re: timer and freeze or program not responding program

    I'm not sure if I let you know or not. I tried reporting a thread as a duplicate, but the reporting form never went away after I hit submit. Eventually, I just closed the browser tab, as it didn't appear to be completing. Sounds like it got through, though.
    My usual boring signature: Nothing

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: timer and freeze or program not responding program

    Quote Originally Posted by codesearcher View Post
    my code is simply like so:

    Code:
    private sub firstfunction()
         do some calculations
         timer1.interval=900000
         timer1.start()
    end sub
    
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
         timer1.stop()
         firstfunction()
    that's just it. I have three forms that uses the same code.
    can you show me the MSDN documentation for do some calculations please.

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: timer and freeze or program not responding program

    Quote Originally Posted by dbasnett View Post
    What makes you think it is hung up? Just wanted to double check that you know that it will be 15 minutes between 'firstfunctions'. Without a better understanding of 'do some calculations' it will be hard to help.
    yes the interval is 15 minutes. actually I just shorten the interval. actually it should be an hour.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width