Click to See Complete Forum and Search --> : Error in _AfxThreadEntry function while creating UI threads.
Narsing
March 1st, 2008, 01:54 AM
Dear All,
Our application is multithreaded application. which is creating and destroying User Interface Threads for handling incoming telephone calls.
after completion of certain creations and destroying the threads (8000 times). Our application is giving assertion failure in thrdcore.cpp
at line no.102. it is showing in _AfxThreadEntry function at below statement.
VERIFY(::SetEvent(pStartup->hEvent));
Please help how to avoid this type of error.
Thanking in advance.
Regards,
Narsing.
Arjay
March 2nd, 2008, 04:41 PM
Open up task manager, switch to the process tab and change the column display to show thread and handle counts (just select all columns for the time being).
Next monitor your program and look at these counts. I suspect you are seeing resource leaks where the handles/memory/threads keep increasing. If so, you'll need to track down the leaks and fix them.
Narsing
March 3rd, 2008, 07:38 AM
Dear Arjay,
Thanks for reply.
We are using :
Visual studio VC++6.0
windows 2000 server with sp4.
when we got error, we have checked the handle and thread counts of our application at that movment the handles and threads counts are
handle count: 360
threads count:19
I am sure that there was no resource leak in our application. How to overcome from this error.
Please kindly help me from this.
Regards,
Narsing.
MikeAThon
March 3rd, 2008, 10:05 AM
Creation and destruction of 8000 threads is probably not a great idea anyway.
Try a thread pool instead, where the threads are not destroyed, but rather go idle while waiting for a new job to be added to a job queue. It's particularly easy to make UI threads go idle, since basically you do nothing. When you want them to do somehting you can PostMessage them a special message which contains (for example) a pointer to some sort of job that they are responsible for executing. This way you would create the threads only once, and they are destroyed only when the entire program shuts down.
Mike
Arjay
March 3rd, 2008, 12:43 PM
For a OS managed thread pool that you don't have to create or manage, check out the QueueUserWorkItem api.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.