We do it something like this:
To add item to queue:
MessageQueue queue = new MessageQueue(pa th);
queue.DefaultPr opertiesToSend. Recoverable = false;
queue.DefaultPr opertiesToSend. Priority = MessagePriority .Normal;
queue.Formatter = new BinaryMessageFo rmatter();
queue.Send(myob ject);
Note that "myobject" must be serializable for this to work.
When reading from the queue you can do it synchronously or asynchronously -
depends on your app. If you have a dedicated app reading a single queue you
could go for synchronously. We have a dedicated app but it reads multiple
queues, so we use the asynchronous method which. This, however, is how to do
it synchronously:
MessageQueue queue = new MessageQueue(pa th);
queue.Formatter = new BinaryMessageFo rmatter();
Object received = queue.Receive() ;
At this point, you can determine what type of object you are dealing with
using the normal is, as or casting methods (eg "if (received is MyClass)"
etc. You can then take the appropriate action for the specific object you
have received.
Looking at MSDN, DataSet is marked as serializable so I don't see why this
wouldn't work with that. SqlCommand isn't serializable so it wouldn't work
(what would be your aim in doing this, as I can't think of a use for it?).
Hope this helps,
Jon
"Jet Leung" <xi**@tom.com > wrote in message
news:Oz******** ******@TK2MSFTN GP10.phx.gbl...
Hi,
Sorry,I can't clearly get what your mean. Could you give me an
example code?
As you said, if an object include data, I can send the object on
queue right? So if I have an dataset or only a command object how can I
send it on queue? After I send it on queue and the revicer get it how
does the revicer know how to handler these data?
e.g an dataset just send it on queue is ok?
e.g an command object how to send it on queue?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!