Results 1 to 2 of 2

Thread: Application state

  1. #1

    Thread Starter
    Member Husko's Avatar
    Join Date
    Nov 2004
    Location
    Michigan
    Posts
    55

    Application state

    I have Form1 creating and showing Form2. When a label on Form2 is clicked an event is raised and then handled in Form1.
    The handler determines the state of my app. States include: Monitoring, Waiting, Closing, Warning.

    How bad of an idea is it to track my apps state by having a global enum int like:

    Dim AppState as integer
    Public enum State
    Monitoring = 1
    Waiting = 2
    Closing = 3
    Warning = 4
    End Enum


    During specific points in the app, I set the app state as needed
    Appstate = State.Monitoring


    Upon events of a timer, I check the apps state
    Select case appstate
    Case State.Monitoring
    ‘do something if monitoring
    Case State.Waiting
    ‘do something if waiting
    Case State.Closing
    ‘do something if closing
    Case State.Warning
    ‘do something if warning.
    End Select


    Is this a really stupid idea?
    Is there a better way?
    I read something about MS application state block but it made no sense to be at all, and to mention it was all in C#

    Thanks!

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Application state

    its not a stupid idea.. but what you would want to do if you go this route... is make your variable a type of the enum and not an integer...

    something like this
    Code:
    Dim AppState as eAppState
    Public enum eAppState
        Monitoring = 1
        Waiting = 2
        Closing = 3
        Warning = 4
    End Enum

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