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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Event Objects

Event Objects

Scheduled Pinned Locked Moved C / C++ / MFC
securityperformancequestion
5 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.
  • S Offline
    S Offline
    sweep123
    wrote on last edited by
    #1

    I have been trying to send an event from a DLL (Dynamically loaded) to a GUI application to display text. I use shared memory for the transfer of data, also in this shared data area in the handle for this event. In the DLL I m_pMsg->hGlobalWriteEvent = CreateEvent(NULL, // no security attributes FALSE, // manual-reset event FALSE, // initial state is signaled "CSLDisplayData" // object name ); Note m_pMsg is a pointer to the shared memory area. Then I send the event:- // Signal GUI to process this request ::SetEvent(m_pMsg->hGlobalWriteEvent); Now in the GUI I have a thread waiting on this event. if (::WaitForSingleObject(ThreadData->m_pMsg->hGlobalWriteEvent, INFINITE) == WAIT_OBJECT_0) { etc But this event in the GUI is never fired. Note I can create and send an event to the thread from the GUI but not from the DLL. What can I do?

    J M 2 Replies Last reply
    0
    • S sweep123

      I have been trying to send an event from a DLL (Dynamically loaded) to a GUI application to display text. I use shared memory for the transfer of data, also in this shared data area in the handle for this event. In the DLL I m_pMsg->hGlobalWriteEvent = CreateEvent(NULL, // no security attributes FALSE, // manual-reset event FALSE, // initial state is signaled "CSLDisplayData" // object name ); Note m_pMsg is a pointer to the shared memory area. Then I send the event:- // Signal GUI to process this request ::SetEvent(m_pMsg->hGlobalWriteEvent); Now in the GUI I have a thread waiting on this event. if (::WaitForSingleObject(ThreadData->m_pMsg->hGlobalWriteEvent, INFINITE) == WAIT_OBJECT_0) { etc But this event in the GUI is never fired. Note I can create and send an event to the thread from the GUI but not from the DLL. What can I do?

      J Offline
      J Offline
      Jens Doose
      wrote on last edited by
      #2

      You do not have to use shared memory in this case. Just create an event in the GUI and in the DLL and use the same name for both CreateEvent calls. That should do the trick. Jens

      S 1 Reply Last reply
      0
      • J Jens Doose

        You do not have to use shared memory in this case. Just create an event in the GUI and in the DLL and use the same name for both CreateEvent calls. That should do the trick. Jens

        S Offline
        S Offline
        sweep123
        wrote on last edited by
        #3

        I have tried that and the only way the events will work if the GUI creates and sets the event. I cant get working the DLL to create and set an event that the GUI will receive. Nothing happens? I thought it was the name that was importance, but decided to use the same handle and that does not work either!!!

        1 Reply Last reply
        0
        • S sweep123

          I have been trying to send an event from a DLL (Dynamically loaded) to a GUI application to display text. I use shared memory for the transfer of data, also in this shared data area in the handle for this event. In the DLL I m_pMsg->hGlobalWriteEvent = CreateEvent(NULL, // no security attributes FALSE, // manual-reset event FALSE, // initial state is signaled "CSLDisplayData" // object name ); Note m_pMsg is a pointer to the shared memory area. Then I send the event:- // Signal GUI to process this request ::SetEvent(m_pMsg->hGlobalWriteEvent); Now in the GUI I have a thread waiting on this event. if (::WaitForSingleObject(ThreadData->m_pMsg->hGlobalWriteEvent, INFINITE) == WAIT_OBJECT_0) { etc But this event in the GUI is never fired. Note I can create and send an event to the thread from the GUI but not from the DLL. What can I do?

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          You can't keep an event handle in shared memory. Handles are process-specific numbers and can only be shared between processes with inheritance or DuplicateHandle(). Each process should call CreateEvent() with the same name. Your parameters also look backwards, it should be auto-reset and initially not signaled. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!

          S 1 Reply Last reply
          0
          • M Michael Dunn

            You can't keep an event handle in shared memory. Handles are process-specific numbers and can only be shared between processes with inheritance or DuplicateHandle(). Each process should call CreateEvent() with the same name. Your parameters also look backwards, it should be auto-reset and initially not signaled. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!

            S Offline
            S Offline
            sweep123
            wrote on last edited by
            #5

            Ok thanks. Now working when CreateEvent call at both ends.

            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