/// <include file='..\..\doc\MessageQueueEnumerator.uex' path='docs/doc[@for="MessageQueueEnumerator.MoveNext"]/*' /> /// <devdoc> /// <para> /// Advances the enumerator to the next queue of the enumeration, if one /// is currently available.</para> /// </devdoc> public bool MoveNext() { MQPROPVARIANTS[] array = new MQPROPVARIANTS[2]; int propertyCount; string currentItem; byte[] currentGuid = new byte[16]; string machineName = null; if (this.criteria != null && this.criteria.FilterMachine) { if (this.criteria.MachineName.CompareTo(".") == 0) { machineName = MessageQueue.ComputerName + "\\"; } else { machineName = this.criteria.MachineName + "\\"; } } do { propertyCount = 2; int status; status = SafeNativeMethods.MQLocateNext(this.Handle, ref propertyCount, array); if (MessageQueue.IsFatalError(status)) { throw new MessageQueueException(status); } if (propertyCount != 2) { this.currentMessageQueue = null; return(false); } //Using Unicode API even on Win9x currentItem = Marshal.PtrToStringUni(array[0].ptr); Marshal.Copy(array[1].ptr, currentGuid, 0, 16); //MSMQ allocated this memory, lets free it. SafeNativeMethods.MQFreeMemory(array[0].ptr); SafeNativeMethods.MQFreeMemory(array[1].ptr); }while (machineName != null && (machineName.Length >= currentItem.Length || String.Compare(machineName, 0, currentItem, 0, machineName.Length, true, CultureInfo.InvariantCulture) != 0)); this.currentMessageQueue = new MessageQueue(currentItem, new Guid(currentGuid)); return(true); }
public bool MoveNext() { string str; MQPROPVARIANTS[] variantArray = new MQPROPVARIANTS[2]; byte[] destination = new byte[0x10]; string strA = null; if ((this.criteria != null) && this.criteria.FilterMachine) { if (this.criteria.MachineName.CompareTo(".") == 0) { strA = MessageQueue.ComputerName + @"\"; } else { strA = this.criteria.MachineName + @"\"; } } do { int propertyCount = 2; int num2 = SafeNativeMethods.MQLocateNext(this.Handle, ref propertyCount, variantArray); if (MessageQueue.IsFatalError(num2)) { throw new MessageQueueException(num2); } if (propertyCount != 2) { this.currentMessageQueue = null; return(false); } str = Marshal.PtrToStringUni(variantArray[0].ptr); Marshal.Copy(variantArray[1].ptr, destination, 0, 0x10); SafeNativeMethods.MQFreeMemory(variantArray[0].ptr); SafeNativeMethods.MQFreeMemory(variantArray[1].ptr); }while ((strA != null) && ((strA.Length >= str.Length) || (string.Compare(strA, 0, str, 0, strA.Length, true, CultureInfo.InvariantCulture) != 0))); this.currentMessageQueue = new MessageQueue(str, new Guid(destination)); return(true); }