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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:55:43+00:00 2026-05-26T02:55:43+00:00

I am new to C# and was trying to write a form a test

  • 0

I am new to C# and was trying to write a form a test a network connection. The idea is that put the connection part in a thread and show a progress dialog during the connection. The following is my code:

Form_TestingConnection testingConnection = new Form_TestingConnection();
Thread t1 = new Thread(TestConnection);

try
{
testingConnection.ShowDialog();
t1.Start();    
}
catch (Exception ex)
{
    Logger.Error(ex);
if (MessageBox.Show(
    Resources.message_connection_issue,
    Resources.title_connection_issue,
    MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
{
    loginSuccessful = false;
}
}

TestConnection is a method to test the connection and set a static member loginSuccessful based on result. The issue I am having now is that the code stuck with testingConnection.ShowDialog(). Whenever it executes to this place, it never goes forward. Any suggestions? Thanks a lot.

  • 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-26T02:55:43+00:00Added an answer on May 26, 2026 at 2:55 am

    ShowDialog shows the form modally. This means that the form will show, all other forms will be disabled, and the ShowDialog function will not return until the modal dialog is closed.

    Use Show instead. This shows the form modeless. When you do that the Show function returns immediately and the form stays open.

    You can think of ShowDialog as being synchronous and Show as being asynchronous.

    Make sure that any methods in the thread which need to update progress on the form are called using Invoke or BeginInvoke to ensure that they run in the context of the main UI thread.

    Finally, your code as it stands does not wait until the thread has done its work. The try/catch block only wraps the form show and the beginning of the thread’s execution (t1.Start()). When you call Start on a thread that call returns asynchronously and the thread continues to do its work. I’m not quite sure what your code is trying to do, but I suspect that the catch block should be inside the thread.

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

Sidebar

Related Questions

I'm new to C# and trying to write a simple GUI Unit Test with
Hey I'm new to java servlets and I am trying to write one that
I'm pretty new to XQuery and I'm trying to write an example function that
I'm trying to write a unit test for a sample project that uses the
I'm trying ot write an integration test for one of my methods, that handles
I'm fairly new to JavaScript and am trying to write some code that lists
I'm trying to write a form that will disable at a certain time and
I'm trying to write an ActiveAdmin form for my Gallery model that has a
I am trying to write a decorator to do logging: def logger(myFunc): def new(*args,
I am new to php and trying to write a login function. Bit stuck

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.