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. General Programming
  3. Visual Basic
  4. VB Timer Control

VB Timer Control

Scheduled Pinned Locked Moved Visual Basic
helpc++comlinuxjson
5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I have created a secure shell in VB that sits in place of the desktop. In this shell there are a number of icons, which when clicked on run up the specified application. This then logs time spent in the application. When it finishes I then just note the time down and work out the elapsed time. However to find when the application finishes I have created a loop that checks whether the application has terminated. So far so good. But now the problem I have is that every 15 minutes I want to create a file of the time spent in each of the applications and send it off to another machine. The timer control in VB will only go on for 1 minute before having to reset it, so thats not really good. I could implement a C++ program to run a timer but then I have the problem in intergrating the two codes together, as the C++ will not know the contents of the variables in the VB application. I had thought about writing the data out to a file as I go (created and opened in the VB code), but then the C++ timer could cause problems in trying to close the file down, and also I would not be able to rest the variables in the VB code easily. Obviously I would like to keep all the code in VB if I could. Also does the timer allow you to come out of the loop that I may be in whilst waiting for a currently running application to finish, and then go back into the loop. Any help would be great. Thanks Simon Kearn (simon.kearn@lmco.com or simon.kearn@ntlworld.com)

    D V 2 Replies Last reply
    0
    • L Lost User

      I have created a secure shell in VB that sits in place of the desktop. In this shell there are a number of icons, which when clicked on run up the specified application. This then logs time spent in the application. When it finishes I then just note the time down and work out the elapsed time. However to find when the application finishes I have created a loop that checks whether the application has terminated. So far so good. But now the problem I have is that every 15 minutes I want to create a file of the time spent in each of the applications and send it off to another machine. The timer control in VB will only go on for 1 minute before having to reset it, so thats not really good. I could implement a C++ program to run a timer but then I have the problem in intergrating the two codes together, as the C++ will not know the contents of the variables in the VB application. I had thought about writing the data out to a file as I go (created and opened in the VB code), but then the C++ timer could cause problems in trying to close the file down, and also I would not be able to rest the variables in the VB code easily. Obviously I would like to keep all the code in VB if I could. Also does the timer allow you to come out of the loop that I may be in whilst waiting for a currently running application to finish, and then go back into the loop. Any help would be great. Thanks Simon Kearn (simon.kearn@lmco.com or simon.kearn@ntlworld.com)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Why now just write your reporting app (in VB of course) without any timer support, then just have the Windows Scheduler Service (Scheduled Tasks) kick off the app every 15 minutes. You could even schedule it to run between the hours of whatever to whatever and on what days. This would, of course, require that you keep your information in a file as it's being created... RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      • L Lost User

        I have created a secure shell in VB that sits in place of the desktop. In this shell there are a number of icons, which when clicked on run up the specified application. This then logs time spent in the application. When it finishes I then just note the time down and work out the elapsed time. However to find when the application finishes I have created a loop that checks whether the application has terminated. So far so good. But now the problem I have is that every 15 minutes I want to create a file of the time spent in each of the applications and send it off to another machine. The timer control in VB will only go on for 1 minute before having to reset it, so thats not really good. I could implement a C++ program to run a timer but then I have the problem in intergrating the two codes together, as the C++ will not know the contents of the variables in the VB application. I had thought about writing the data out to a file as I go (created and opened in the VB code), but then the C++ timer could cause problems in trying to close the file down, and also I would not be able to rest the variables in the VB code easily. Obviously I would like to keep all the code in VB if I could. Also does the timer allow you to come out of the loop that I may be in whilst waiting for a currently running application to finish, and then go back into the loop. Any help would be great. Thanks Simon Kearn (simon.kearn@lmco.com or simon.kearn@ntlworld.com)

        V Offline
        V Offline
        VBGuruWantabe
        wrote on last edited by
        #3

        Dim i as Integer 'In your init routine Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles Timer1.Tick i += 1 'Increment for each minute - Interval set to 60,000 If i > 14 Then 'Do your file stuff here as 15 minutes have elapsed i=0 End If End Sub If "to err is human", programmers must be superhuman...

        L 1 Reply Last reply
        0
        • V VBGuruWantabe

          Dim i as Integer 'In your init routine Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles Timer1.Tick i += 1 'Increment for each minute - Interval set to 60,000 If i > 14 Then 'Do your file stuff here as 15 minutes have elapsed i=0 End If End Sub If "to err is human", programmers must be superhuman...

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Thanks for that. On the other issue; if I am in a loop at the time of the timer Interval expiring. Will I get returned back into the loop once the timer procedure has been completed. Can't seem to find any info on whether this will happen or not. Ta, Simes

          D 1 Reply Last reply
          0
          • L Lost User

            Thanks for that. On the other issue; if I am in a loop at the time of the timer Interval expiring. Will I get returned back into the loop once the timer procedure has been completed. Can't seem to find any info on whether this will happen or not. Ta, Simes

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            You'll never actually leave the loop. You MUST put a Application.DoEvents in the loop, somewhere where it will execute fairly often, so your app will get the Timer Tick events and be able to process them. As a general rule, without the DoEvents, your app will stay in the loop and only execute the stacked up events when the loop terminates and the function that it's in gives up control to the GUI again. RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

            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