CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: AfxBeginThread

  1. #1
    Join Date
    Sep 2003
    Posts
    90

    AfxBeginThread

    Iam creating a worker thread using AfxBeginThread inside a COM Inproc DLL and when i call the particular function through the thread it take more CPU time than
    the one without a thread.....why is this happening ?

  2. #2
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: AfxBeginThread

    When you create the worker thread, what is it doing when it has no work to do? Is it in a tight loop waiting for work, or does is suspend itself until its told that more work is available?
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  3. #3
    Join Date
    Sep 2003
    Posts
    90

    Re: AfxBeginThread

    I call a particular global function through the AfxBeginbthread.
    I give a Normal priority for this message.
    When i click a mouse button this thread will be started and it does not wait
    for anything.

  4. #4
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: AfxBeginThread

    [ Moved thread ]

  5. #5
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: AfxBeginThread

    Sounds like some sort of COM marshalling is going on.

    In single apartment threaded COM objects the calls to methods are marshalled - i.e. the methods aren't actually called directly but run through a 'seperation' mechanism.

    If you start up your app in a multi threaded apartment mode and enable your com object to support 'both' single & multi threaded apartments I think you'll find that it won't slow down.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

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