예제 #1
0
        public static SharedMemoryIPC Connect(string sharedMemoryIPCName, FileMapAccess fileMapAccess)
        {
            SharedMemory    sharedMemory = Open(sharedMemoryIPCName, fileMapAccess);
            EventWaitHandle serverEvent;
            EventWaitHandle clientEvent;


            string serverEventName = sharedMemory.ReadString(0);

            try
            {
                serverEvent = EventWaitHandle.OpenExisting(serverEventName);
                clientEvent = EventWaitHandle.OpenExisting(sharedMemory.ReadString(serverEventName.Length + 1));
            }
            catch (Win32Exception ex)
            {
                if (ex.ErrorCode == 0x000010d8)
                {
                    throw new NoServerException();
                }
                else
                {
                    throw;
                }
            }

            clientEvent.Set();

            return(new SharedMemoryIPC(sharedMemory, serverEvent, clientEvent));
        }
예제 #2
0
        SharedMemoryIPC(SharedMemory sharedMemory, EventWaitHandle serverEvent, EventWaitHandle clientEvent)
        {
            this.sharedMemory = sharedMemory;
            this.serverEvent  = serverEvent;
            this.clientEvent  = clientEvent;

            role = CLIENT;
        }
예제 #3
0
        void initializeKernelObjects(string name, uint size, FileMapProtection fileMapProtection, string serverEventName, string clientEventName)
        {
            bool newCreatedSrEvent;
            bool newCreatedClEvent;

            sharedMemory = Create(name, size, FileMapProtection.PageExecuteReadWrite);

            serverEvent = new EventWaitHandle(false, EventResetMode.ManualReset, serverEventName, out newCreatedSrEvent);
            if (newCreatedSrEvent != true)
            {
                throw new ObjectAlreadyExistException(serverEventName);
            }

            clientEvent = new EventWaitHandle(false, EventResetMode.ManualReset, clientEventName, out newCreatedClEvent);
            if (newCreatedClEvent != true)
            {
                throw new ObjectAlreadyExistException(clientEventName);
            }
        }