Home > Software engineering >  Process communication (message queue) WinCE/MFC
Process communication (message queue) WinCE/MFC

Time:09-18

Requirements: a program written in VS2005 the message queue, to realize the synchronous communication between sending and receiving process; The message queue is empty when the receiving process can't receive and output to the user's information: "queue empty"; Unable to send and send message queue full process output to the user's information: "full", synchronization mechanism using API function please make your own choice,

Has already written code:
 
HANDLE HMSGQ;
MSGQUEUEOPTIONS mqo.
Mqo. BReadAccess=FALSE;
Mqo. CbMaxMessage=32;
Mqo. DwFlags=MSGQUEUE_ALLOW_BROKEN;
Mqo. DwMaxMessages=3;//the message queue capacity 3
Mqo. DwSize=sizeof (MSGQUEUEOPTIONS);
TCHAR * writebuf=new TCHAR [32].
HMSGQ=CreateMsgQueue (L "MsgQueue", & amp; Mqo);//create a new message queue or according to the name to open the message queue
//write message
BOOL val=WriteMsgQueue (HMSGQ writebuf, 32, INFINITE, 0).//write messages into the queue


Q: at this point, how do I know if the queue is full, or know that there are few messages in the queue?
Use the GetMsgQueueinfo () can be implemented? Request a great god can give routines ~

CodePudding user response:

In general, there are many ways of judgment, XX is full
1, counter - statistics of data in the queue, enter + 1, pop-up - 1
2, traverse the queue, if (leng=maxlen) full
3, write data failure
4...
5...

CodePudding user response:

Traverse the queue, if (leng=maxlen) full, unable to send
  • Related