Sat, September 30, 2006, 09:36 AM under
MobileAndEmbedded
Over the last year I have had a few people contact me with questions relating to the Point to Point Message Queue class I wrote for MSDN. This blog entry will serve as a URL where I can point future questions regarding it.1. It seems that under certain circumstances, on certain platforms, the queue does not close properly. A possible solution is to declare a dedicated named event that you create in the ctor of the queue. Set it in the
Close
method. In the
Monitor
method, change the
WaitForSingleObject
to
WaitForMultipleObjects
and include this new event.
2. It also seems that under certain other conditions (that amongst other things include multiple senders) the class spikes the cpu. This is due to the way the native API works and the solution is not to run the thread that is responsible for raising events. To do that, follow the advice of the article and create a new P2PMessageQueueSender class that inherits from the original one and simply overrides the
StartEventThread
with an empty method (
Note that this solution should also work for the 1st issue described above)
3. If you are porting the code to NETCF v2.0 (when I wrote the article it wasn’t released yet), there are things you can do to the code other than simply recompiling it, such as making any worker threads to background (IsBackground=true) .
Of course, the easiest thing for you to do is none of the above. Simply get the
SDF from OpenNETCF, which will include the above improvements (plus you can then get support from the team as opposed to the “as is” code of my old msdn article ;-)).
For other NETCF questions, please use the newsgroup and forum...