Accessing MFC-Objects from other threads than the primary
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

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

  1. #1
    Join Date
    Aug 1999
    Location
    Darmstadt, FRG
    Posts
    86

    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
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,544

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,051

    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
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,544

    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
    6,051

    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

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center