Beispiel #1
0
 /// <summary>
 /// Instanciate a new Interprocess Mailbox.
 /// </summary>
 /// <param name="name">The name for the Win32 semaphores and the shared memory file.</param>
 /// <param name="size">The size of the shared memory in terms of bytes.</param>
 public ProcessMailBox(string name, int size)
 {
     empty = new ProcessSemaphore(name + ".EmptySemaphore.MailBox", 1, 1);
     full  = new ProcessSemaphore(name + ".FullSemaphore.MailBox", 0, 1);
     file  = MemoryMappedFile.CreateFile(name + ".MemoryMappedFile.MailBox", MemoryMappedFile.FileAccess.ReadWrite, size);
     view  = file.CreateView(0, size, MemoryMappedFileView.ViewAccess.ReadWrite);
 }
 /// <summary>
 /// Instanciate a new Interprocess Mailbox.
 /// </summary>
 /// <param name="name">The name for the Win32 semaphores and the shared memory file.</param>
 /// <param name="size">The size of the shared memory in terms of bytes.</param>
 public ProcessMailBox(string name,int size)
 {
     empty = new ProcessSemaphore(name+".EmptySemaphore.MailBox",1,1);
     full = new ProcessSemaphore(name+".FullSemaphore.MailBox",0,1);
     file = MemoryMappedFile.CreateFile(name+".MemoryMappedFile.MailBox",MemoryMappedFile.FileAccess.ReadWrite,size);
     view = file.CreateView(0,size,MemoryMappedFileView.ViewAccess.ReadWrite);
 }
        /// <summary>
        /// Instanciates an Inter-Process message channel.
        /// </summary>
        /// <param name="size">The count of messages the channel can queue before it blocks.</param>
        /// <param name="name">The channel's name. Must be the same for all instances using this channel.</param>
        /// <param name="maxBytesPerEntry">The maximum serialized message size in terms of bytes. Must be the same for all instances using this channel.</param>
        public ProcessChannel( int size, string name, int maxBytesPerEntry)
        {
            int fileSize = 64+size*maxBytesPerEntry;

            empty = new ProcessSemaphore(name+".EmptySemaphore.Channel",size,size);
            full = new ProcessSemaphore(name+".FullSemaphore.Channel",0,size);
            mutex = new ProcessSemaphore(name+".MutexSemaphore.Channel",1,1);
            file = MemoryMappedFile.CreateFile(name+".MemoryMappedFile.Channel",MemoryMappedFile.FileAccess.ReadWrite,fileSize);
            view = file.CreateView(0,fileSize,MemoryMappedFileView.ViewAccess.ReadWrite);
            queue = new MemoryMappedQueue(view,size,maxBytesPerEntry,true,0);
            if(queue.Length < size || queue.BytesPerEntry < maxBytesPerEntry)
                throw new MemoryMappedArrayFailedException();
        }
Beispiel #4
0
        /// <summary>
        /// Instanciates an Inter-Process message channel.
        /// </summary>
        /// <param name="size">The count of messages the channel can queue before it blocks.</param>
        /// <param name="name">The channel's name. Must be the same for all instances using this channel.</param>
        /// <param name="maxBytesPerEntry">The maximum serialized message size in terms of bytes. Must be the same for all instances using this channel.</param>
        public ProcessChannel(int size, string name, int maxBytesPerEntry)
        {
            int fileSize = 64 + size * maxBytesPerEntry;

            empty = new ProcessSemaphore(name + ".EmptySemaphore.Channel", size, size);
            full  = new ProcessSemaphore(name + ".FullSemaphore.Channel", 0, size);
            mutex = new ProcessSemaphore(name + ".MutexSemaphore.Channel", 1, 1);
            file  = MemoryMappedFile.CreateFile(name + ".MemoryMappedFile.Channel", MemoryMappedFile.FileAccess.ReadWrite, fileSize);
            view  = file.CreateView(0, fileSize, MemoryMappedFileView.ViewAccess.ReadWrite);
            queue = new MemoryMappedQueue(view, size, maxBytesPerEntry, true, 0);
            if (queue.Length < size || queue.BytesPerEntry < maxBytesPerEntry)
            {
                throw new MemoryMappedArrayFailedException();
            }
        }
 /// <summary>
 /// Instanciates an Inter-Process rendez-vous.
 /// </summary>
 /// <param name="localName">A name for the local synchronization. Must match the remote partner's remoteName but must NOT mucht your own remoteName.</param>
 /// <param name="remoteName">A name for the remote synchronization. Must match the temote partner's localName but must NOT mucht your own localName.</param>
 public ProcessRendezVous(string localName, string remoteName)
 {
     local = new ProcessSemaphore("RendezVous_"+localName,0,1);
     remote = new ProcessSemaphore("RendezVous_"+remoteName,0,1);
 }
 /// <summary>
 /// Instanciates an Inter-Process rendez-vous.
 /// </summary>
 /// <param name="localName">A name for the local synchronization. Must match the remote partner's remoteName but must NOT mucht your own remoteName.</param>
 /// <param name="remoteName">A name for the remote synchronization. Must match the temote partner's localName but must NOT mucht your own localName.</param>
 public ProcessRendezVous(string localName, string remoteName)
 {
     local  = new ProcessSemaphore("RendezVous_" + localName, 0);
     remote = new ProcessSemaphore("RendezVous_" + remoteName, 0);
 }