12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- //------------------------------------------------------------------------------
- // <copyright file="MessageEnumerator.cs" company="Microsoft">
- // Copyright (c) Microsoft Corporation. All rights reserved.
- // </copyright>
- //------------------------------------------------------------------------------
- using Experimental.System.Messaging.Interop;
- using System;
- namespace Experimental.System.Messaging
- {
- public sealed class Cursor : IDisposable
- {
- private CursorHandle handle;
- private bool disposed;
- internal Cursor(MessageQueue queue)
- {
- CursorHandle result;
- int status = SafeNativeMethods.MQCreateCursor(queue.MQInfo.ReadHandle, out result);
- if (MessageQueue.IsFatalError(status))
- throw new MessageQueueException(status);
- this.handle = result;
- }
- internal CursorHandle Handle
- {
- get
- {
- if (disposed)
- {
- throw new ObjectDisposedException(GetType().Name);
- }
- return handle;
- }
- }
- public void Close()
- {
- if (handle != null)
- {
- handle.Close();
- handle = null;
- }
- }
- public void Dispose()
- {
- this.Close();
- this.disposed = true;
- }
- }
- }
|