CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    Darmstadt, FRG
    Posts
    76

    Accessing MFC-Objects from other threads than the primary

    I'm using a graphics library within an application. Functions of the library were accessed from a different than the application's primary thread. There were crashes which could be traced back to the said library. The developer told me that there are problems when functions are called from other threads. That's not my problem at this point - But: Are there any general restrictions for MFC- or Win32-Objects when being accessed from other that the main thread? If there are any, is there a good source for retrieving further information?
    Thanks for any support in advance!

  2. #2
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,185

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,536

    Re: Accessing MFC-Objects from other threads than the primary

    Are there any general restrictions for MFC- or Win32-Objects when being accessed from other that the main thread?
    For MFC window objects, yes there is. And no there's not for Win32 objects. MFC window object is restricted to be used only in the thread it was created in, and therefore must not be called across threads. However, window handle wrapped by the MFC object can be used across threads without any limitation.
    Best regards,
    Igor

  4. #4
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,185

    Re: Accessing MFC-Objects from other threads than the primary

    Quote Originally Posted by Igor Vartanov View Post
    ... However, window handle wrapped by the MFC object can be used across threads without any limitation.
    ... however, sending messages (SendMessage) to some HWND belonging to another thread may cause a deadlock.
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,536

    Re: Accessing MFC-Objects from other threads than the primary

    Sure, but this is not a limitation. Just a very specific case.
    Best regards,
    Igor

+ Reply to Thread

Bookmarks

Posting Permissions

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



HTML5 Development Center

Click Here to Expand Forum to Full Width