How do I know when dllmain is finished?
According to this MSDN post :
During process startup and DLL initialization procedures, new threads can be created, but they do not start until DLL initialization is done for the process.
If this is true, then you should be able to do your work on the topic in question, which does not start until DLLMain finishes. Of course, this leaves some of the timing issues open. If you are using Mutex, maybe you can fix this problem.
NOTE. I haven't tried this, it just looks like it could theoretically work.
PS If you try, please ask for a comment on whether it works or not.
a source to share
From my point of view, this has long been a problem. If the DLL is being used by third party applications that you have no control over, then it is difficult to get other applications to call some initialization function. Ultimately this may be a requirement, but it is certainly a good idea not to do so in order to use a DLL (like winsock initialization).
If an initialization call is not possible, it is likely that you need to rely on lazy initialization, which happens on demand. I came across some pretty decent paper on DLL Best Practices that might be worth reading. It has a nice list of specific things you can and cannot do inside DLLMain. I know from experience that they need to be adhered to (the list is "not necessary").
a source to share