unsafe int TryRelockMessage(long lookupId) { int retCode = 0; ITransaction internalTrans; using (MsmqEmptyMessage message = new MsmqEmptyMessage()) { IntPtr nativePropertiesPointer = message.Pin(); try { // don't want other threads receiving the message we want to relock lock (this.receiveLock) { MsmqQueueHandle handle = GetHandle(); TransactionLookupEntry entry; lock (this.internalStateLock) { if (!this.lockMap.TryGetValue(lookupId, out entry)) { // should never get here return(retCode); } if (entry.MsmqInternalTransaction == null) { retCode = UnsafeNativeMethods.MQBeginTransaction(out internalTrans); if (retCode != 0) { return(retCode); } retCode = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, UnsafeNativeMethods.MQ_LOOKUP_RECEIVE_CURRENT, nativePropertiesPointer, null, IntPtr.Zero, internalTrans); if (retCode != 0) { BOID boid = new BOID(); internalTrans.Abort( ref boid, // pboidReason 0, // fRetaining 0 // fAsync ); return(retCode); } entry.MsmqInternalTransaction = internalTrans; } } } } finally { message.Unpin(); } } return(retCode); }
private int TryRelockMessage(long lookupId) { int num = 0; using (MsmqEmptyMessage message = new MsmqEmptyMessage()) { IntPtr properties = message.Pin(); try { lock (this.receiveLock) { MsmqQueueHandle handle = base.GetHandle(); lock (this.internalStateLock) { TransactionLookupEntry entry; if (this.lockMap.TryGetValue(lookupId, out entry)) { ITransaction transaction; if (entry.MsmqInternalTransaction != null) { return(num); } num = UnsafeNativeMethods.MQBeginTransaction(out transaction); if (num != 0) { return(num); } num = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, 0x40000020, properties, null, IntPtr.Zero, transaction); if (num != 0) { BOID pboidReason = new BOID(); transaction.Abort(ref pboidReason, 0, 0); return(num); } entry.MsmqInternalTransaction = transaction; } return(num); } return(num); } return(num); } finally { message.Unpin(); } } return(num); }
unsafe int TryRelockMessage(long lookupId) { int retCode = 0; ITransaction internalTrans; using (MsmqEmptyMessage message = new MsmqEmptyMessage()) { IntPtr nativePropertiesPointer = message.Pin(); try { // don't want other threads receiving the message we want to relock lock (this.receiveLock) { MsmqQueueHandle handle = GetHandle(); TransactionLookupEntry entry; lock (this.internalStateLock) { if (!this.lockMap.TryGetValue(lookupId, out entry)) { // should never get here return retCode; } if (entry.MsmqInternalTransaction == null) { retCode = UnsafeNativeMethods.MQBeginTransaction(out internalTrans); if (retCode != 0) { return retCode; } retCode = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, UnsafeNativeMethods.MQ_LOOKUP_RECEIVE_CURRENT, nativePropertiesPointer, null, IntPtr.Zero, internalTrans); if (retCode != 0) { BOID boid = new BOID(); internalTrans.Abort( ref boid, // pboidReason 0, // fRetaining 0 // fAsync ); return retCode; } entry.MsmqInternalTransaction = internalTrans; } } } } finally { message.Unpin(); } } return retCode; }
private int TryRelockMessage(long lookupId) { int num = 0; using (MsmqEmptyMessage message = new MsmqEmptyMessage()) { IntPtr properties = message.Pin(); try { lock (this.receiveLock) { MsmqQueueHandle handle = base.GetHandle(); lock (this.internalStateLock) { TransactionLookupEntry entry; if (this.lockMap.TryGetValue(lookupId, out entry)) { ITransaction transaction; if (entry.MsmqInternalTransaction != null) { return num; } num = UnsafeNativeMethods.MQBeginTransaction(out transaction); if (num != 0) { return num; } num = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, 0x40000020, properties, null, IntPtr.Zero, transaction); if (num != 0) { BOID pboidReason = new BOID(); transaction.Abort(ref pboidReason, 0, 0); return num; } entry.MsmqInternalTransaction = transaction; } return num; } return num; } return num; } finally { message.Unpin(); } } return num; }