Solved

Mailbox Events

Posted on 2000-05-02
4
303 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now