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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:43:15+00:00 2026-05-11T13:43:15+00:00

Hey all. I’m trying to see about handling events in a console application. I

  • 0

Hey all. I’m trying to see about handling events in a console application. I would prefer to not use silent WinForms (though I understand that that’s one way) to do it. I’ve read over a similar question and its response. See response text below (link):

The basic requirement of an STA thread is that it needs to run a message pump. In Windows Forms, you can use Application.Run. Or you could write the message pump by hand, using user32!GetMessage & DispatchMessage. But it’s probably easier to use the one in WinForms or WPF.

What the basic structure of a program that uses ‘user32 -> GetMessage’ & ‘user32 -> DispatchMessage’?

  • 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. 2026-05-11T13:43:16+00:00Added an answer on May 11, 2026 at 1:43 pm

    See the topic ‘Using Messages and Message Queues’ in MSDN (under Win32 and COM Development > User Interface > Windows User Experience > Windows Management > Windows User Interface > Windowing > Messages and Message Queues; you’ll probably need to take a look at the other articles and samples in the same section). Quick summary, omitting error handling and using C syntax rather than C# for reasons discussed below:

    RegisterClass(...); CreateWindow(...); ShowWindow(...);  // probably not in your case while (GetMessage(&msg, NULL, 0, 0)) {   TranslateMessage(&msg);   DispatchMessage(&msg); } 

    As you can see from the window setup boilerplate, this still relies on ‘silent windows,’ albeit created and message-pumped via the Win32 API rather than through WinForms. So you’re not really gaining anything by doing this way. Hence my feeling there’s not much point translating this stuff into C# — if the only solution to your problem is an invisible window, you may as well use an invisible Windows Form and all the friendly wrappers that come with that platform.

    However, if you’re not actually using a Windows Forms control like the poster of the linked question, then you can quite happily use .NET events in a console application. The restriction to STA and the need for a message pump is specific to receiving events from WinForms and ActiveX controls like the WebBrowser (or messages from Win32 HWNDs, though that doesn’t necessarily require STA).

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

Sidebar

Related Questions

Hey all i am trying to use javascript with my jsp file as under:
Hey all i am trying to find some code that would allow me to
hey all, i have a question about urlmapping in grails. I'm trying to make
Hey all I'm trying to make a 3d game in with 2d sprite characters.
Hey All, I currently use Google's API to include jQuery into my sites like
hey all my question about how the developers makes their interface the buttons, slider,
Hey all. I'm trying to set a value on a hidden form element based
Hey all, i am trying to learn how to insert a comment within some
Hey all, i am trying to get my bottom bar to center on the
Hey all i am trying to delete a key from the registery but i

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.