Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3607910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:26:07+00:00 2026-05-18T21:26:07+00:00

I have a windows form application that will open other forms, but will only

  • 0

I have a windows form application that will open other forms, but will only display the forms for a few seconds (user configurable). I would normally do something like threading.thread.sleep(n), however when doing this the forms controls do not load only the white background shows, and I have also been reading that this isnt the best practice for what I am after as user input will not be actioned until the thread wakes up.

I have come across people using System.Timers.Timer(n), but I am struggling to get this to work for me, the form will only open and close straight away (you can only see a flash as the form opens then closes).

The code that I am using is:

Private Shared tmr As New System.Timers.Timer    
aForm.Show()
tmr = New System.Timers.Timer(aSleep * 60 * 60)
tmr.Enabled = True

aForm.Close()

This is all contained within a Private sub that passes the form and the defined run time.

My intention is to have the main application running from the task bar, which then calls one of the forms that will display for a defined period of time, close the form, then call another one of the forms.

Is any able to point me in the right direction for why the form opens then closes without seeing through the defined run time (I have been testing with 10 seconds), or is there a better way of doing what I am seeking?

Your help is greatly appreciated.

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:26:08+00:00Added an answer on May 18, 2026 at 9:26 pm

    the docs say there’s an Elapsed event handler that gets called when the time elapses. You would close the form in the handler:

    http://msdn.microsoft.com/en-us/library/system.timers.timer%28VS.85%29.aspx

    I just wrote a little example that shows what you would need to do at:

    http://www.antiyes.com/close-form-after-10-seconds

    Below is the relevant code, the full solution can be downloaded from the article.

    Form 1 code

    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim frm2 As New Form2()
            frm2.ShowDialog()
        End Sub
    
    End Class
    

    Form 2 code

    Imports System.Timers
    
    Public Class Form2
    
        Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
            MyBase.OnLoad(e)
            Dim tmr As New System.Timers.Timer()
            tmr.Interval = 5000
            tmr.Enabled = True
            tmr.Start()
            AddHandler tmr.Elapsed, AddressOf OnTimedEvent
        End Sub
    
        Private Delegate Sub CloseFormCallback()
    
        Private Sub CloseForm()
            If InvokeRequired Then
                Dim d As New CloseFormCallback(AddressOf CloseForm)
                Invoke(d, Nothing)
            Else
                Close()
            End If
        End Sub
    
        Private Sub OnTimedEvent(ByVal sender As Object, ByVal e As ElapsedEventArgs)
            CloseForm()
        End Sub
    
    End Class
    

    Of course for this code to work you’d need forms setup with the buttons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows forms application that I am adding a request support form
I have an application that is written in VB.NET, using the System.Windows.Forms.Form as the
I have a windows form application that uses a Shared class to house all
I created my ClickOnce application witch will install a small windows form application that
I'm building a web application that will automatically complete user forms online for many
Background : I have a C# Windows Forms application that contains a Windows service
I have been developing a C# windows form application in XP. It all works
I have a Windows Form that takes quite a bit of time to load
I have a simple .NET 2.0 windows form app that runs off of a
I have a few listview controls on a windows form and i've assigned a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.