Vb App - Schedule?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    Vb App - Schedule?

    I am having a problem with an App i've tried a couple different routes..


    I need to call a function in one of my vb apps at set times. Even while logged out of the "server" its going to be running on... So I have my app running as a service but even with my api timer the function never fires. Any help on this would be appreciated.

    -- the function fires at the set time if i'm logged into the computer with the app open at set time --
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by iam_clint
    I need to call a function in one of my vb apps at set times. Even while logged out of the "server" its going to be running on... So I have my app running as a service but even with my api timer the function never fires. Any help on this would be appreciated.
    -- the function fires at the set time if i'm logged into the computer with the app open at set time --
    Hi could you post the code used to fire the function.
    Daniel(~_~)

    Comment

    • iam_clint
      Recognized Expert Top Contributor
      • Jul 2006
      • 1207

      #3
      Code:
      Public WithEvents mobjTmr As vbAPITimerTools.APITimer
      'on initiate it does this
      Set mobjTmr = New vbAPITimerTools.APITimer
      mobjTmr.StartTimer 100
      Code:
      Private Sub mobjTmr_Refresh()
          Dim curTime As Date
          curTime = Time
          strDate = Format(curTime, "HH:MM:SS AM/PM")
          ccTime.Caption = strDate
          If (strDate = "2:01:00 AM") Then
              Call Form_Load
              Call Command1_Click
          End If
      End Sub

      Comment

      • daniel aristidou
        Contributor
        • Aug 2007
        • 494

        #4
        Originally posted by iam_clint
        Code:
        Public WithEvents mobjTmr As vbAPITimerTools.APITimer
        'on initiate it does this
        Set mobjTmr = New vbAPITimerTools.APITimer
        mobjTmr.StartTimer 100
        Code:
        Private Sub mobjTmr_Refresh()
        Dim curTime As Date
        curTime = Time
        strDate = Format(curTime, "HH:MM:SS AM/PM")
        ccTime.Caption = strDate
        If (strDate = "2:01:00 AM") Then
        Call Form_Load
        Call Command1_Click
        End If
        End Sub
        Hi ..
        Try changing this line...
        [CODE=vb] strDate = Format(curTime, "HH:MM:SS AM/PM")
        ccTime.Caption = strDate
        If (strDate = "2:01:00 AM") Then
        Call Form_Load
        'To
        strDate = Format(curTime, "HH:MM AM/PM")
        ccTime.Caption = strDate
        If (strDate = "2:01 AM") Then
        Call Form_Load
        [/CODE]
        Question just to be sure the 100 in this line is the interval?
        mobjTmr.StartTi mer 100

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by daniel aristidou
          [CODE=vb] strDate = Format(curTime, "HH:MM:SS AM/PM")
          ...
          strDate = Format(curTime, "HH:MM AM/PM")[/CODE]
          Why would changing the time format make any difference? In fact, wouldn't this potentially cause the process to happen multiple times when it's only wanted once? Or does the "100" mean ten seconds, or something?

          Comment

          • iam_clint
            Recognized Expert Top Contributor
            • Jul 2006
            • 1207

            #6
            100 is 100 milliseconds and changing the time format shouldn't change anything since when I am logged in the app fires on time every time...
            100 milliseconds should hit within that 1 second period about 9 times at least. but since the app would be busy it wouldn't hit it more than once. the app takes well over 30 minutes to finish what its doing.

            when i'm not logged into the system (not logged in... not shut down just not logged in) it doesn't fire.

            Comment

            • daniel aristidou
              Contributor
              • Aug 2007
              • 494

              #7
              Originally posted by iam_clint
              100 is 100 milliseconds and changing the time format shouldn't change anything since when I am logged in the app fires on time every time...
              100 milliseconds should hit within that 1 second period about 9 times at least. but since the app would be busy it wouldn't hit it more than once. the app takes well over 30 minutes to finish what its doing.

              when i'm not logged into the system (not logged in... not shut down just not logged in) it doesn't fire.
              To make things Clear........
              The if Statement never returns True?
              Or
              When The If statement = True ;you get no results?
              Also
              Does the loggin have any relation to the timer you are using? To check this you might want to try disableing the login function....
              I think the problem might be to do with the login...
              Can explain the login logic you are using.

              Comment

              • iam_clint
                Recognized Expert Top Contributor
                • Jul 2006
                • 1207

                #8
                Originally posted by daniel aristidou
                To make things Clear........
                The if Statement never returns True?
                Or
                When The If statement = True ;you get no results?
                Also
                Does the loggin have any relation to the timer you are using? To check this you might want to try disableing the login function....
                I think the problem might be to do with the login...
                Can explain the login logic you are using.
                Not a login for the app .. Windows login

                No relation to the timer.


                the events fire when the app is running and logged into windows

                when the app is running and your not logged into windows no events fire.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  I don't know whether it matters, but what version of Windows?

                  Also, I'm thinking this question might be better handled in the Windows forum, as it's probably not a language-specific issue. If I'm reading it correctly, you just need to know how to get an application loaded as a service to process timer events when nobody is logged in.

                  Comment

                  • iam_clint
                    Recognized Expert Top Contributor
                    • Jul 2006
                    • 1207

                    #10
                    its windows 2003 server

                    Comment

                    • WinblowsME
                      New Member
                      • Jan 2008
                      • 58

                      #11
                      How about using the Task Scheduler?

                      Comment

                      • kadghar
                        Recognized Expert Top Contributor
                        • Apr 2007
                        • 1302

                        #12
                        Originally posted by Killer42
                        Why would changing the time format make any difference? In fact, wouldn't this potentially cause the process to happen multiple times when it's only wanted once? Or does the "100" mean ten seconds, or something?

                        I dont think its such a weird idea, i think that while working with dates, its better to use an interval in the IF rather than an exact time.
                        i.e.

                        you may be so lucky that if you say
                        [CODE=vb]If MyTime = "2:30 AM" then
                        'Do something
                        End if[/CODE]
                        Will work if the timer tics in that very moment

                        But i'd say that something like:
                        [CODE=vb]
                        if mytime >= "2:30 AM" and mytime < "2:31 AM" then
                        'Do something
                        End if[/CODE]
                        with a larger interval will do

                        But since you dont know the speed of the users computer, to make sure the event will only happen once, but it'll certainly happen, write (inside the timer) something like

                        [CODE=vb]Dim Boo1 as boolean
                        If mytime <= "2.30 AM" then boo1=true
                        if mytime >= "2.30 AM" and Boo1 = true then
                        'Do something
                        boo1=false
                        end if[/CODE]

                        or any other variant of "using a boolean to only do it once" will help.

                        Comment

                        • kadghar
                          Recognized Expert Top Contributor
                          • Apr 2007
                          • 1302

                          #13
                          Originally posted by iam_clint
                          its windows 2003 server
                          I dont know where does it gets the time from, if its from the logged in client, why dont you try making your "own clock" in the app that refreshes each time somebody is logged in, so when nobody is, instead of checking the system's time, it'll check the one you created.

                          This might give you some headaches, cause if nobody logs in for a while, it wont be sharp on time. But it's an alternative in case you dont find how to call the time when nobody is logged in.

                          Comment

                          • iam_clint
                            Recognized Expert Top Contributor
                            • Jul 2006
                            • 1207

                            #14
                            (this is my server its running on i know its settings.) the app won't fire while i'm "logged off" of windows.. but the app will fire while i'm "logged in" windows.

                            You think that the system time changes or doesn't update while a user isn't logged in?

                            Comment

                            Working...