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 6196339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:37:34+00:00 2026-05-24T03:37:34+00:00

I have a series of methods being called for my networking code. An event

  • 0

I have a series of methods being called for my networking code. An event gets fired from the networking thread. Inside this event, which I’ve hooked into from a singleton class, I route messages to form level methods which they register on form load to handle certain messages they care about. Inside of these form message hooks I need to close the current form (which I was able to do) but also show a different one (which is giving me the trouble).

The new form sort of shows but it’s hanging/not updating. I’m sure this has something to do with that form because it’s .Show() was basically called from another thread (sort of) doesn’t have a message loop, but I’m not sure how else to solve this. The network message that gets received indicates on the client machine what forms to close and show.

The flow might be confusing so I’ll try better to explain.

Login form attaches user defined functions inside that form to a singleton class list of messages. For example when a message called LOGIN_STATUS is fired I assign a function from the Login form to a list defined in this singleton class.

The singleton class has the network class defined in it which actually runs on another thread, but this is all handled inside the class. In the private ctor I subscribe to the OnData event of this network class.

When OnData gets fired from the network class to the singleton class it passes to it the type of data. I loop through the list of function pointers to see if any of them are linked to LOGIN_STATUS and if so call them. This will call the Login forms function. Inside that function I need to close the Login form and open the Lobby form. That’s when the Lobby form shows, but is hung up and not updating.

Hope that makes sense.

This is all being done in VB.NET where I have the “close when last form closed” setting on which is what I want. VB.NET also makes it easier to manage forms since I can just for formname.Show() instead of having to keep a list of the forms and manage them myself like in C# so if that’s still possible with the solution that would be ideal.

  • 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-24T03:37:34+00:00Added an answer on May 24, 2026 at 3:37 am

    If you want to ensure all forms are created on the same thread, and hence the same message loop, use the main from’s Invoke method. The Form.Invoke and Form.BeginInvoke methods cause the code to run from the form’s message loop. BeginInvoke allows the event calling thread to return immediately, where-as Invoke blocks the event thread until the method is complete. It depends how time sensitive your code is.

    Private Sub OpenFormEvent(sender As Object, e As EventArgs)
        If MainForm.InvokeRequired Then
            Dim args As Object() = {sender, e}
            MainForm.BeginInvoke(New EventHandler(AddressOf OpenFormEvent), args)
        Else
            Dim SecondForm As New Form()
            SecondForm.Show()
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of Extension methods to help with null-checking on IDataRecord objects,
I have a series of ASCII flat files coming in from a mainframe to
I have a series of CodedUI test methods that make up a single test
I have a series of methods to write, but I think there is some
I have a timer executing a loop executing a series of threads. Each thread
I have a series of methods, with similar structure and sharing a common parameter:
I have a series of XML files which can be retrieved, edited and saved
So thanks to many of the replies from this board, I have a much
I have a series of PDFs named sequentially like so: 01_foo.pdf 02_bar.pdf 03_baz.pdf etc.
I have a series of functional tests against a web application that correctly run,

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.