CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    2

    Question Error in _AfxThreadEntry function while creating UI threads.

    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.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Error in _AfxThreadEntry function while creating UI threads.

    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.

  3. #3
    Join Date
    Mar 2008
    Posts
    2

    Question Re: Error in _AfxThreadEntry function while creating UI threads.

    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.

  4. #4
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Error in _AfxThreadEntry function while creating UI threads.

    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

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Error in _AfxThreadEntry function while creating UI threads.

    For a OS managed thread pool that you don't have to create or manage, check out the QueueUserWorkItem api.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured