Why not work with MSMQ directly?
private void OnReceiveCompleted(Object source,
ReceiveCompletedEventArgs asyncResult)
{
try
{
MessageQueue mq = (MessageQueue)source;
if (mq != null)
{
Message message = null;
try
{
message = mq.EndReceive(asyncResult.AsyncResult);
}
catch (Exception ex)
{
....
}
mq.BeginReceive();
if (message != null)
{
QueuedDeviceInput queuedInput =
message.Body as QueuedDeviceInput;
if (queuedInput != null)
{
.....
}
}
}
return;
}
catch (Exception exc)
{
...
}
}
QueuedDeviceInput
is a
[Serializable]
type.
mq.BeginReceive();
enable asych invocation of
OnReceiveCompleted
once more, enabling paralell execution from that point on.
This will, as far as I'm able to determine from your question, behave in the required manner.
Regards
Espen Harlinn