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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:19:33+00:00 2026-05-13T08:19:33+00:00

Say I have a DLL that has the following static/global: ClassA Object; Along with

  • 0

Say I have a DLL that has the following static/global:

ClassA Object;

Along with the implementation of ClassA, it also contains a ‘regular’ ClassB, which will not work properly if ClassA has not been constructed yet (which is why I’ve made ClassA is a static/global).

In Windows, I believe that the DLL loader will load this DLL on the call to ClassB’s constructor, correct? At this point, ClassA will be constructed and then ClassB’s construction will follow. If a second thread comes along and constructs ClassB, ClassA will not be constructed as it has already been constructed.

Now, my question is — what if ClassB is constructed simultaneously by two threads. So Thread 1 will start to construct ClassA. Will Thread 2 wait until ClassA is completely constructed before executing ClassB’s constructor?

In other words, does LoadLibrary() use a CriticalSection to ensure thread-safe initialization of a DLL’s static/globals? My hunch is ‘yes’, but I can’t seem to find any documentation saying one way or the other.

  • 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-13T08:19:34+00:00Added an answer on May 13, 2026 at 8:19 am

    DllMain is called by the Windows loader while holding an internal critical section known as the “loader lock,” so your static constructors will be called during the DLL_PROCESS_ATTACH event, which only occurs once, when your DLL is first loaded.

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

Sidebar

Related Questions

I recently got a dll that has been implemented by others. I have to
Here's my problem: I have an object that's referencing a DLL. I would like
Let's say you have a class library project that has any number of supplemental
I have a GUI app, that has a button added. Within several plugin dll's,
I have a plugin that creates an object that has an event. Is there
In my solution I have a DLL project, say Project1 , that owns a
Lets say we have this scenario a setup that deploys a .net com dll
I want to get coverage of let's say CoverageTarget.dll. I have a test.dll to
I have a managed class library (say mylib.dll) and a 3rd party managed app
Say i have a few fields like the following: abd738927 jaksm234234 hfk342 ndma0834 jon99322

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.