How to: Object to pointer/handle and pointer/handle to Object

  • Thread starter Thread starter Johann
  • Start date Start date
J

Johann

Hi,
I'm using message queue and would like to know how do I return a IntPtr to
the MessageQueue object I created in
IntPtr MessageQueueCreate(string name){
MessageQueue mq = new MessageQueue.Create(".\Private$\"+name);
return ??
....
}

and How do I use that IntPtr to get back the object (to enqueue a message)
MessageQueueEnqueue(IntPtr ptr, Message mes){
....
}
Thx,

Johann
 
oh that's bad. because your pointer isn't guaranteed to point to the same
block of memory since it is pushed into another process (queue) and may run
on another machine. Instead, you really should move the data itself into the
queue. I can certainly see why it is more efficient to move a pointer around
instead of the actual data but it just isn't safe without a lot of thought
going into the design.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top