-
September 30th, 2004, 10:20 AM
#1
[RESOLVED] Can we create threads in Dll?
I understand we can call any API's inside a DLL but just curious can we create threads as well? For example we call a function from the dll and that function in turn create some thread (like serial port input thread). Can we do that?
-
September 30th, 2004, 10:22 AM
#2
Re: Can we create threads in Dll?
I know no reason why this shouldn't be possible.
-
September 30th, 2004, 11:15 AM
#3
Re: Can we create threads in Dll?
Definitely! A process maps a DLL into its address spaces. Threads created within the DLL are part of the host's process address spaces.
Kuphryn
-
September 30th, 2004, 11:17 AM
#4
Re: Can we create threads in Dll?
-
October 1st, 2004, 02:15 PM
#5
Re: Can we create threads in Dll?
-
June 12th, 2009, 03:12 PM
#6
Re: Can we create threads in Dll?
how?
I created a DLL in which it creates several threads, but when I use it in an MFC project, it always gets crashed, both in Debug mode and Release mode.
I changed this DLL to a single win32 console project, it runs correctly both in Debug and Release mode.
What's the trick creating multiple threads in dll?
Thanks,
Yuping
-
June 12th, 2009, 03:36 PM
#7
Re: Can we create threads in Dll?
There is no trick to it. It sounds like there's a bug somewhere in your DLL (or EXE). What crashes and where? Have you looked at it in the debugger?
Viggy
-
April 5th, 2018, 01:01 AM
#8
Re: Can we create threads in Dll?
Hi, I know this is an old thread. I am working on porting an old win32 DLL to support win64. Part of this update requires replacement of an API, the new API uses threads for background functions. I have tried creating the threads in the DLL and found that despite _beginthreadex returning a valid handle the thread doesn't run. I'm Attaching to the DLL using Visual Studio and I can see the call to _beginthreadex is successful but the thread body never runs.
I've put the same code into a standalone application and it works fine, what could the problem be?
-
April 5th, 2018, 01:13 AM
#9
Re: Can we create threads in Dll?
Solved....In DllMain there was a call to DisableThreadLibraryCalls(hInstance), which I missed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|