Using Timer To Close MsgBox?

Discussion in 'Questions (Windows Mobile)' started by cdeane, May 8, 2008.

  1. cdeane

    cdeane Member

    How can I close out a MsgBox after 5 sec. of show time?
  2. Erel

    Erel Administrator Staff Member Licensed User

    Interesting question with a nice solution:
    Sub App_Start
        timer1.Interval = 
        timer1.Enabled = 
    Msgbox("Some Message","title",cMsgboxOK)
        timer1.Enabled = 
    End Sub

    Sub Timer1_Tick
        Timer1.Enabled = 
    End Sub
  3. cdeane

    cdeane Member

    Thanks Erel

    That's the ticket.
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    How is this possible?
    I would have expected to need DoEvents or Agraham's Threading library as I thought the MsgBox would normally halt program execution.
    Yet it is obvious here that the Tick events are still caught even though the program is in the middle of running App_Start. :confused:

  5. Erel

    Erel Administrator Staff Member Licensed User

    While the main (and only) thread waits for the msgbox to be closed it is free to handle other events.
    Most user events will not happen as the form and all its controls are blocked until the msgbox is closed, however the timer continues to raise events.
  6. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Thanks for the response, I understand now.
  7. mjcoon

    mjcoon Well-Known Member Licensed User

    Ah, I see now, rather too late, that I should have written a local wrapper Sub for MsgBox() calls that stopped my constantly-running timer while the message is shown, so that the program does not have to deal with the accumulated (and now useless) queued timer events afterwards!

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice