Solved

Mailbox Events

Posted on 2000-05-02
4
316 Views
Last Modified: 2013-11-20
How can I receive "notifications"/events when information is written into a mailslot?

I would thus like to do something like
WaitForSingleObject(SlotWriteEvent, INFINITE) or something equivalent, instead of polling the mailslot

0
Comment
Question by:OD
  • 3
4 Comments
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2829118
When you create the mailslot, specify MAILSLOT_WAIT_FOREVER for the lReadTimeout parameter.
0
 
LVL 1

Accepted Solution

by:
poohbear_68 earned 50 total points
ID: 2829127
Or if you want to switch between the modes you can use the following code:

SetMailslotInfo(hMailslot, 0);  // Return immediately
SetMailslotInfo(hMailslot, MAILSLOT_WAIT_FOREVER);  // Return when message arrives
0
 

Author Comment

by:OD
ID: 2832023
PoohBear,

Your answer does make sense to me and I think I will probably accept the answer (I can not test if for another week or so). Just a general question before I accept, can I "peek" into the mailslot, thus retrieve a message without removing it from the slot? (Especially for variable length messages, so that I can check a header with the message length)
0
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2834086
You cannot read from a mailslot without removing the data.  But you can retrieve the length of the next message using GetMailslotInfo.

// You must initilize hMailslot to the value returned by CreateMailslot
DWORD dwSizeOfNextMessage;
GetMailslotInfo(hMailslot, NULL, dwSizeOfNextMessage, NULL, NULL);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 66
MaxSpan challenge 9 124
Use of condition with 'serial' in ansible 2 88
I could not set window to top 4 45
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question