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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:49:20+00:00 2026-06-09T16:49:20+00:00

In my application I have a modal dialog which contains about 20 different combo

  • 0

In my application I have a modal dialog which contains about 20 different combo boxes which are bind to certain fields in the databases. The database is huge and on the loading of dialog I have to load all the combo boxes from the databases. So I setup 20 threads (1 each for every combo box).

Everything works fine, but the problem only occurs when the user closes the dialog with close or cancel button or OK button while the threads are running; in that case the application crashes.

I have tried to terminate the threads prematurely as well but that does not help. Here is the thread termination code

if(m_iNoOfThreadsCompleted != m_iTotalThreads)      
{
        for(int i = 0; i < m_iTotalThreads - 1; i++)
    {
            if (m_threads[i] != NULL)
        {
            GetExitCodeThread(m_threads[i]->m_hThread, &exit_code);
            if(exit_code == STILL_ACTIVE)
                CloseHandle(m_threads[i]->m_hThread);
        }
        if(m_iNoOfThreadsCompleted == m_iTotalThreads)
            break;
    }
}

What is the issue? Or do I need to use a better approach?

  • 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-06-09T16:49:22+00:00Added an answer on June 9, 2026 at 4:49 pm

    Synchronizing threads is generally done using events.

    // Before Creating threads
    HANDLE hEndEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
    // Pass handle to threads
    

    Then on termination

    SetEvent(hEndEvent);
    WaitForMultipleObjects(m_iTotalThreads,m_threads,TRUE,INFINITE); // Wait for all threads to end
    
    // Loop through and close all the thread handles
    

    Note that you need to be occasionally looking for the end event to be set otherwise your threads won’t end.

    // In Thread
    if (WaitForSingleObject(hEndEvent,0)==WAIT_OBJECT_0) {
        // Clean up
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ruby-on-rails application, which shows a modal dialog form for first-time users.
I have an application where I can launch a modal dialog box over a
We have an application which, as its first UI action, displays a modal JDialog
I have a modal dialog which contain form and hidden iframe to which form
I am invoking a jquery modal dialog in which I have a save button.
I have a jquery-ui-dialog that contains a <form> which contains a <input type=file >
I have an existing web application which uses window.showmodaldialog() to show certain forms and
In an asp.net web application, I have a modal popup built with a Telerik
I'd like to show an input modal in my WinForm application. I have looked
in my zf application i have base model class Application_Model, which connects to db

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.