Run two winform windows simultaneously
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Running two WinForms windows at the same time is normal in desktop applications, but the correct implementation depends on what “simultaneously” means. In most cases, you simply open two forms on the same UI thread. Only more advanced cases require separate UI threads, and that extra complexity should be avoided unless you truly need isolated message loops.
Open Multiple Forms on the Same UI Thread
For ordinary desktop apps, both forms can run on the main WinForms UI thread. The important part is that each form has its own window, while the application still uses one message loop.
This is the standard pattern. Both windows stay responsive because the WinForms message loop continues to run while the forms are shown.
Use Show, Not ShowDialog, When Both Must Stay Active
If you call ShowDialog, the second form becomes modal and blocks interaction with the owner until it closes.
Use Show() when the windows should remain independently usable. Use ShowDialog() only when the second window is meant to be a blocking dialog.
Keep Work Off the UI Thread
If one or both windows become unresponsive, the problem is often not “too many forms.” It is that long-running work is happening on the UI thread.
Move expensive work to the background and marshal UI updates back to the form:
This is usually the real fix when people think they need extra UI threads.
Use a Separate UI Thread Only for Special Cases
In rare situations, you may want a completely separate UI thread with its own message loop. That is much more complex and should be reserved for cases where the window truly needs isolation.
This works, but cross-thread communication becomes harder and all UI interactions must respect thread affinity. For most applications, opening both forms on the same UI thread is simpler and safer.
Coordinate Form Lifetime Carefully
If the second window should outlive the first, think about application shutdown rules. By default, closing the main form passed to Application.Run usually ends the app.
If you need different behavior, you may need to:
- hide instead of close the main form
- manage lifetime through an
ApplicationContext - explicitly coordinate form shutdown order
That is an application-lifetime concern, not a “two windows” limitation.
Common Pitfalls
The biggest mistake is using ShowDialog() and then wondering why the other window cannot be used at the same time.
Another issue is putting long-running work on the UI thread and blaming WinForms for the freeze.
People also jump to multiple UI threads too early, which makes cross-thread coordination harder than necessary.
Summary
- Most WinForms apps should show multiple windows on the same UI thread.
- Use
Show()for parallel windows andShowDialog()only for modal dialogs. - Keep long-running work off the UI thread so both forms stay responsive.
- Reach for separate UI threads only in special cases that truly need isolated message loops.
- Treat application shutdown and form lifetime as a separate design concern.
Related reading
- Runnable with a parameter?
- Running blocking code in Tornado
- Running code in main thread from another thread
- Running code in main thread from another thread
- Running Azure functions locally gives No runtime error after .NET7 upgrade
- Running MSIL on GPU
- Running code in main thread from another thread
- Running each Spring Scheduler in its own thread

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.