Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mailbox Events

Posted on 2000-05-02
4
Medium Priority
?
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Expert Comment

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

Accepted Solution

by:
poohbear_68 earned 150 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 2

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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. …
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 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