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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:52:30+00:00 2026-05-23T03:52:30+00:00

ORIGINAL QUESTION Our application uses CSocket which requires the message pump to be running

  • 0

ORIGINAL QUESTION

Our application uses CSocket which requires the message pump to be running in order for it to work. Currently it’s not practical to change to another socket implementation, though that is where we’d like to end up at some point.

The application is in Visual C++ (NOT managed).

We currently launch the C++ DLL by using a C#.NET service launcher that kicks off a thread with an Application.Run to get the message pump going, and then uses DllImport to fire off the start method in our DLL.

There are numerous problems with this, the most pressing of which is that if the DLL crashes for any reason we don’t get a dump file!

As a result of this, we’re switching to a C++ service launcher, and while we’re fine with the service aspect of it we’re a bit stumped on how to get the message pump going.

I had a look around google and some questions on here but part of my problem is a lack of basic C++ knowledge so apologies if this is a dupe question, if someone can point me in the right direction that would be much appreciated.

Many thanks in advance
Matt Peddlesden

MORE INFORMATION

The current C# service that we are trying to replace does essentially this:

public void PumpThread()
{
    DLLStart();
    Application.Run();
}

protected override void OnStart(string[] args)
{
    try
    {
        Thread pumpThread = new Thread(new ThreadStart(PumpThread));
        pumpThread.IsBackground = true;
        pumpThread.Start();
    }
    catch (DllNotFoundException dnfe)
    {
    }
    catch (Exception e)
    {
    }
}

protected override void OnStop()
{
    try
    {
        DLLStop();
    }
    catch (DllNotFoundException dnfe)
    {
    }
    catch (Exception e)
    {
    }
}

Essentially we’re simply trying to replace the above C# .NET Windows Service with a C++ equivalent so that our code is running entirely in the unmanaged world rather than unnecessarily confusing this with 5 lines of managed code.

DLLStart() and DLLStop() are two functions that are imported from our C+ Unmanaged DLL that actually start and stop the system.

I’m not entirely sure what kind of Visual C++ project this would need to be in order to be able to do anything with the pump either to be honest.

Hope this additional data is useful.

  • 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-23T03:52:30+00:00Added an answer on May 23, 2026 at 3:52 am

    My translated C++ code is below (not checked 🙂
    PS: Calling DLLStart, DLLStop in the same thread will be more reliable.

    A global variable holds threadID
    DWORD threadID = 0;

    In OnStart equivalent:
    CreateThread(0, 0, PumpThread, 0, 0, 0);

    In OnStop equivalent:
    PostThreadMessage(threadID, WM_QUIT, 0, 0);

    Thread routine:

    DWORD WINAPI PumpThread(void* param)
    {
        threadID = GetCurrentThreadId();  
    
        DLLStart();  
    
        // create thread message queue
        PeekMessage(&msg, 0, WM_USER, WM_USER, PM_NOREMOVE);  
    
        MSG msg;
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    
        DLLStop();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Original Question What I'd like is not a standard C pre-processor, but a variation
I work with a team that uses Behaviour Driven Development(BDD) to deliver our applications.
Original Question I want to be able to generate a new (fully valid) MP3
Original Question I am looking for a function that attempts to quantify how distant
Original Question I am writting a logging class where the goal is to be
(The original question was asked there : http://www.ogre3d.org/phpBB2/viewtopic.php?t=44832 ) Someone asked : While I
The original question is below, but I changed the title because I think it
I've editing this original question as I think I've narrowed down the problem... I
Due to a lack of response to my original question , probably due to
I was asked to post this as a question on StackOverflow by http://twitter.com/jonathanjulian which

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.