Inheritance: IDisposable
示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessMailBox"/> class.
 /// </summary>
 /// <param name="name">
 /// The name for the semaphores and the shared memory file.
 /// </param>
 public ProcessMailBox(string name, TimeSpan sendReceiveTimeout)
 {
     this.sendReceiveTimeout = sendReceiveTimeout;
     this.ChannelName        = name;
     this.mailBoxSync        = new SendReceiveLock(name + ".FullMutex.MailBox", name + ".EmptyMutex.MailBox");
     this.file = MemoryMappedFile.CreateOrOpen(
         name + ".MemoryMappedFile.MailBox",
         ChannelConfiguration.Instance.ChannelSize,
         MemoryMappedFileAccess.ReadWrite);
     this.view =
         new MemoryMappedFileView(
             this.file.CreateViewStream(
                 0, ChannelConfiguration.Instance.ChannelSize, MemoryMappedFileAccess.ReadWrite));
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessMailBox"/> class.
 /// </summary>
 /// <param name="name">
 /// The name for the semaphores and the shared memory file.
 /// </param>
 public ProcessMailBox(string name, TimeSpan sendReceiveTimeout)
 {
     this.sendReceiveTimeout = sendReceiveTimeout;
     this.ChannelName = name;
     this.mailBoxSync = new SendReceiveLock(name + ".FullMutex.MailBox", name + ".EmptyMutex.MailBox");
     this.file = MemoryMappedFile.CreateOrOpen(
         name + ".MemoryMappedFile.MailBox",
         ChannelConfiguration.Instance.ChannelSize,
         MemoryMappedFileAccess.ReadWrite);
     this.view =
         new MemoryMappedFileView(
             this.file.CreateViewStream(
                 0, ChannelConfiguration.Instance.ChannelSize, MemoryMappedFileAccess.ReadWrite));
 }
示例#3
0
        private void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                this.view.Dispose();
                this.file.Dispose();
                Task.Factory.StartNew(() => this.mailBoxSync.Dispose());
            }

            this.view        = null;
            this.file        = null;
            this.mailBoxSync = null;

            this.disposed = true;
        }
示例#4
0
        private void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                this.view.Dispose();
                this.file.Dispose();
                Task.Factory.StartNew(() => this.mailBoxSync.Dispose());
            }

            this.view = null;
            this.file = null;
            this.mailBoxSync = null;

            this.disposed = true;
        }