CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    13

    Various questions...

    I am trying to develop a program that does specific actions at certain intervals of time. I have been using a Timer control set at a 1 second interval and using a variable to store the number of seconds, then I compare it to the length of time that I want the actions to take place. (that sounds confusing) Is there a way to base my actions off the time of the computer rather than using a Timer control?

    Also, what is the best way to restrict the user from clicking buttons while actions are happening? (Like when a program is loading or performing a large function) I have tried changing the mouse cursor to the hourglass and disabling the form, but it did not yeild the results I wanted.

    I would appreciated any information that might be helpful. Thanks!

    Ryan


  2. #2
    Join Date
    Jan 2001
    Location
    Germany
    Posts
    222

    Re: Various questions...

    I think using a timer control is the easiest way to do some actions in certain intervals of time. You can easily check if an action is to happen:

    Dim seconds as Long

    Sub timer1_Timer()
    'Task execution may last some time so disable timer so long
    timer1.Enabled = false

    'A task happening every 5 seconds
    If seconds Mod 5 = 0 then
    'Do whatever task 1 does
    End If
    If seconds Mod 7 = 0 then
    'Do whatever task 2 does
    End If
    ...

    'let the timer continue
    timer1.Enabled = true
    End Sub



    You'll just have to do something to prevent seconds from getting larger than a Long variable may be.
    And the best way of preventing the user from pressing a button would be to set button.Enabled = false

    .

    ----------------
    You can contact me directly at [email protected]
    Hey, and... don't forget your parsley cause you can't eat your dog after having stolen him from some animal shelter and having drowned him in the Atlantic Ocean.
    Teamwork Software - Stuff That Does Something

  3. #3
    Join Date
    Apr 2001
    Posts
    27

    Re: Second Part

    As to the second part of your question regarding stoping user interaction there are a few ways depending on the situation.

    Upon Loading the program use a splash screen to not show your main form until necessary. That is use a Sub Main function with a splash screen..

    While the Hourglass is a good indicator that the user shouldnt do anything it will allow some user interaction. Many times it is necessary to disable controls that may interfere with long functions. And re-enable them when the operation is finished.

    The progress bar also reinforces this to the user..

    I prefer to keep long operations off the forms and into modules or dlls..

    The main problem I have is when the user WANTS interaction in a long operation. Then I resort to the DO legacy function, which i cant get around in VB...


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

Featured