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

  • Home
  • SEARCH
  • 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 3755492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:42:26+00:00 2026-05-19T09:42:26+00:00

I am working on a C# WinForms app, and I want it to be

  • 0

I am working on a C# WinForms app, and I want it to be able to pop open a non-modal dialog which will get redrawn and be interactive at the same time as the main window/form.

The main window is using a SerialPort and displaying data transfer counts, which are continually increasing via a SerialDataReceivedEventHandler.

I can use ShowDialog() which seems to work in a modal fashion, but the main window data counters freeze while the dialog is in use, and I think eventually the serial buffers are overrun.

I think I want to use Show(), but if I do this the dialog appears on screen half-drawn, then is not drawn or interactive any more (gets trashed if I drag another window across it). It stays onscreen until I close the main app window.

Perhaps I should be starting another thread or, likely, am just doing something wrong. I don’t usually do C# or Windows programming (maybe you can tell.)

Edit after comments (thanks, commenters):

I think maybe most things are getting run under whatever thread the serial receive event handler gets called under. When starting up my app I create a class to handle the serial, which includes:

com.DataReceived += new SerialDataReceivedEventHandler(SerialRxHandler);

The only code that I have written to care about threads is some functions to update the counters and log listbox, which I found had to be wrapped with some InvokeRequired to stop me getting complaints about thread switching:

delegate void SetCountDelegate(TextBox tb, int count);
internal void SetCount(TextBox tb, int count) {
    // thread switch magic
    if (InvokeRequired) {
        BeginInvoke(new SetCountDelegate(SetCount), new object[] { tb, count });
    } else {
        tb.Text = String.Format("{0}", count);
    }
}

So maybe I shouldn’t be trying to Show() a form on this thread. Another InvokeRequired block, or should I be doing things completely differently?

  • 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-19T09:42:27+00:00Added an answer on May 19, 2026 at 9:42 am

    Suppose I’ll answer myself..

    Prompted by commenters and a bit of thinking, I did an Invoke() to switch to the UI thread before trying to create and Show() my child dialog. That worked.

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

Sidebar

Related Questions

we have WinForms app which stores data in SQL Server (2000, we are working
I have a WinForms application in which I want to be able to provide
We are working on a winforms app in Visual Studio 2005 and the setup
I'm working on a WinForms app and I have a user control in it.
I'm working on a WinForms app and need to record the location of MouseDown
I am working on a WinForms app in C#, VS2008. How do I setup
I'm working on a .NET WinForms app that needs to print a FEDEX shipping
I am working on a VB.NET WinForms app that was upgraded by Visual Studio
I have a DataGridView control in a winforms app that I'm working on. The
I'm attempting to deploy a WinForms app in a Citrix environment. It's been working

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.