Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WIN32 Multithreaded Dll

WIN32 Multithreaded Dll

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpannouncement
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JRaiden
    wrote on last edited by
    #1

    I was wondering if someone could help me out with Multi-threading. I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine. any ideas or sample examples of Win32 DLL Multithreading (no MFC) Raiden

    G S 2 Replies Last reply
    0
    • J JRaiden

      I was wondering if someone could help me out with Multi-threading. I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine. any ideas or sample examples of Win32 DLL Multithreading (no MFC) Raiden

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      You're probably doing your screen updates from your threads using SendMessage, right? Unfortunately, when you call SendMessage from a thread that doesn't own the window, it switches threads to make the call. This has the effect of blocking the calling thread. Try doing screen updates using PostMessage instead.


      Software Zen: delete this;

      Fold With Us![^]

      J 1 Reply Last reply
      0
      • G Gary R Wheeler

        You're probably doing your screen updates from your threads using SendMessage, right? Unfortunately, when you call SendMessage from a thread that doesn't own the window, it switches threads to make the call. This has the effect of blocking the calling thread. Try doing screen updates using PostMessage instead.


        Software Zen: delete this;

        Fold With Us![^]

        J Offline
        J Offline
        JRaiden
        wrote on last edited by
        #3

        Thanks for the reply Garry, I'm actually using callbacks: to return text from the dll to update say a label of the engines location on the gui. dThreadCallBack is a DWORD thats stores the static members address location void StdScanner::CallBackFunction (char *cSomeStringToSend) { typedef int (__stdcall* lpMyCallBack) (LPSTR szMsg); lpMyCallBack MyCallBack; MyCallBack = (lpMyCallBack) dThreadCallBack; MyCallBack(cSomeStringToSend); } Normally this function works perfectly when outside threads, but locks up when I use it in threads. Do you have any examples/source of generic Multithreaded Win32 DLLs (non mfc) that can interact with a gui (be it MFC or WIN32). Raiden

        1 Reply Last reply
        0
        • J JRaiden

          I was wondering if someone could help me out with Multi-threading. I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine. any ideas or sample examples of Win32 DLL Multithreading (no MFC) Raiden

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Where is it locking up? If you break into it with the debugger and get a callstack of what's going on when it locks up this would be a big help. Note - When you write a multithreaded program you have to start worrying about the thread safety of every function you call - I suspect this may be your problem. Steve

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups