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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:27:58+00:00 2026-05-14T06:27:58+00:00

I think I am making a simple mistake, but since I noticed there are

  • 0

I think I am making a simple mistake, but since I noticed there are many boost experts here, I thought I would ask for help.

I am trying to use boost threads(1_40) on windows xp. The main program loads a dll, starts the thread like so (note this is not in a class, the static does not mean static to a class but private to the file).

static boost::thread network_thread;
static bool quit = false;
HANDLE quitEvent;

//some code omitted for clarity, ask if you think it would help
void network_start()
{
  HANDLE *waitHandles = (HANDLE*)malloc(3 * sizeof(HANDLE));
  waitHandles[0] = quitEvent;
  waitHandles[1] = recvEvent;
  waitHandles[2] = pendingEvent;
  do {
      //read network stuff, or quit event
      dwEvents =WaitForMultipleObjects(3, waitHandles, FALSE, timeout);
   } while (!quit)
}

DllClass::InitInstance() 
{
}

DllClass::ExportedFunction()
{
   network_thread = boost::thread(boost::bind<void>(network_start));
}


DllClass::ExitInstance()
{
  //signal quit (which works)
   quit = true;
   SetEvent(QuitEvent);
   //the following code is slightly verbose because I'm trying to figure out what's wrong
    try {
       if (network_thread.joinable() ) {
           network_thread.join();
         } else {
            TRACE("Too late!");
        }
   } catch (boost::thread_interrupted&) {
        TRACE("NET INTERRUPTED");
    }
}

The problem is that the main thread is hanging on the join, and the network thread is hanging at the end of _endthreadex. What am I misunderstanding?

  • 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-14T06:27:58+00:00Added an answer on May 14, 2026 at 6:27 am

    You are not supposed to create/end threads in InitInstance/ExitInstance,

    see http://support.microsoft.com/default.aspx?scid=kb;EN-US;142243 for more info. Also, see http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx about DllMain in general.

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

Sidebar

Related Questions

Okay, I think I'm just making a stupid mistake here, but I want to
I know I must be making a simple syntax mistake, but I want to
I think I might be making a mistake here. I am getting the following
I'm making a simple learning simulation, where there are multiple organisms on screen. They're
Alright, here's my dillema. I am making a simple application with Qt Creator that
Here's the deal, I've been working on making a simple screen locker app that
I'm making a simple voxel engine (think Minecraft) and am currently at the stage
There might be some very simple answer to this, but i am really stuck
I'm doing a pretty simple thing here, making a POST request to Django from
Which do you think are best practices for making a windows dialog compatible both

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.