[rabbitmq-discuss] IModel / thread sharing

Tony Garnock-Jones tonyg at lshift.net
Mon Sep 14 16:45:11 BST 2009

Ashley van Gerven wrote:
> The .NET user guide states that IModel instances should not be shared
> accross threads. So having multiple web requests publishing to the queue
> using the same IModel instance is not an option.

Well, not without somehow ensuring that there are no concurrent accesses
to the object, in any case. Here's what the guide says:

 If more than one thread needs to access a particular IModel
 instances, the application should enforce mutual exclusion itself. One
 way of achieving this is for all users of an IModel to lock the
 instance itself:

  IModel ch = RetrieveSomeSharedIModelInstance();
  lock (ch) {

 [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
 []  [] http://www.lshift.net/ | Email: tonyg at lshift.net

More information about the rabbitmq-discuss mailing list