Announcement

Collapse
No announcement yet.

hs.Waitevents

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    hs.Waitevents

    Isn't the purpose of hs.WaitEvents to override the normal 30-second timeout that occurs if a script is in a waiting state? Is there any magic mumbo-jumbo involved in invoking it? I have a script that has a 2-minute pause [hs.WaitSecs(120)] and I don't want that box to pop up in the middle of it. So I put

    hs.WaitEvents
    hs.WaitSecs(120)

    Do I have to turn off the hs.WaitEvents afterwards or something?


    Jim Speiser
    35-year veteran of Home Automation
    Still don't know squat

    #2
    Originally posted by JimSpy View Post
    Isn't the purpose of hs.WaitEvents to override the normal 30-second timeout that occurs if a script is in a waiting state? Is there any magic mumbo-jumbo involved in invoking it?
    It appears that "hs.WaitEvents()" is pretty much the same thing as "Application.DoEvents()" (standard VB.Net). It simply pauses the script, checks to see if any other things are ready to run, runs them, then resumes the script. Your hs.WaitSecs() should also pause the script, in pretty much the same way.

    Run a test and see. Generally the WaitEvents call is used when you have an involved processing loop, in order to allow other things to continue to run. If you do not have a WaitEvents in that loop, after 30 seconds the system will think that loop is an infinite loop.

    Comment


      #3
      VB.NET scripts in HS3 run in their own thread and hs.Waitevents will only affect the script thread and nothing else. Unless you have a processing loop for checking something, it does nothing. hs.Waitsecs suspends the thread until the duration is reached. As it is suspended, the 30 second timeout does not come into play.


      Jon

      Comment


        #4
        OK, but maybe I should elucidate on the problem I'm having: It worked the first time I ran it. It did not work the second time. Does that tell you anything? Is there a loop that needs to be closed or something? And I don't have parentheses following the hs.WaitEvents call; the docs do not call for them. Do I still need them?


        Jim Speiser
        35-year veteran of Home Automation
        Still don't know squat

        Comment


          #5
          Originally posted by JimSpy View Post
          It worked the first time I ran it. It did not work the second time.
          I would need to see your script file, and more information on what happens when its run the second time (symptoms? Error message? Log Entries?). And I would probably remove the WaitEvents statement entirely, since you have the WaitSecs there.

          Comment


            #6
            Originally posted by jon00 View Post
            VB.NET scripts in HS3 run in their own thread and hs.Waitevents will only affect the script thread and nothing else. Unless you have a processing loop for checking something, it does nothing. hs.Waitsecs suspends the thread until the duration is reached. As it is suspended, the 30 second timeout does not come into play.
            I'm wondering if WaitEvents is a vestigial holdover from VBScript days. It may serve no useful purpose in a vb.net script.

            Mike____________________________________________________________ __________________
            HS3 Pro Edition 3.0.0.548, NUC i3

            HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

            Comment


              #7
              Originally posted by Uncle Michael View Post
              I'm wondering if WaitEvents is a vestigial holdover from VBScript days. It may serve no useful purpose in a vb.net script.
              That's what I thought, however in the HS3 docs, the example is written in VB.NET

              http://help.homeseer.com/help/HS3/st...pts_waitevents

              Personally, I've never had a VB.NET script time out so perhaps the document writer just updated the HS2 docs without really knowing?
              Jon

              Comment


                #8
                Originally posted by Uncle Michael View Post
                I'm wondering if WaitEvents is a vestigial holdover from VBScript days. It may serve no useful purpose in a vb.net script.
                As I described upthread, hs.waitevents appears to be the same or similar thing as "Application.DoEvents()". Since it has its own thread, the need to process other system messages is less important, but it does inform hs that the script is not in an infinite loop. Also, even if it is in its own separate thread, a processor intensive loop can negatively impact other processes.

                I use it all the time in normal Windows applications when doing a loop, and it does seem to improve other applications throughput. Using it has the side benefit of allowing the updating of a progress bar so that the user can see how far along we are.

                However, I to do not see much reason to have such a processor intensive loop in an HS script.

                Comment


                  #9
                  Originally posted by jon00 View Post

                  Personally, I've never had a VB.NET script time out so perhaps the document writer just updated the HS2 docs without really knowing?
                  I agree, the document writer who created that example did not fully understand what it does.

                  Comment


                    #10
                    Well, if the doc writer didn't understand, then what chance do I have??? Ya know what, this doesn't have to wait 2 minutes, it can go ahead after 28 seconds. That solves everything!


                    Jim Speiser
                    35-year veteran of Home Automation
                    Still don't know squat

                    Comment

                    Working...
                    X