internal virtual IPCDispatchResult DoDispatchSyncMessage(IPCBaseSyncMessage message, IPCBaseMessagesQueue receaverQueue)
        {
            // ensure that IPC server is alive
            if (!ChannelServices.RegisteredChannels.Any(i => i.ChannelName == _dispatcherID.Value))
            {
                serverChannel = new IpcServerChannel(_dispatcherID.Value, _dispatcherID.Value);
                if (!ChannelServices.RegisteredChannels.Any(i => i == serverChannel))
                {
                    ChannelServices.RegisterChannel(serverChannel, false);
                }
            }

            // share object
            RemotingServices.Marshal(message,
                                     message.UriSuffix,
                                     message.GetType());
            try {
                // notify receaver
                IIPCGUID             helperID      = new IPCGUID(message.GetHashCode());
                IPCSyncHelperMessage helperMessage = new IPCSyncHelperMessage(new IPCUri(_dispatcherID, message).Value, message.GetType(), helperID);
                helperMessage.DispatherID = _dispatcherID;
                message.DispatherID       = _dispatcherID;
                receaverQueue.EnqueueMessage(helperMessage);
                _receaverWaitHandle.Set();
                if (!_dispatcherWaitHandle.WaitOne(message.TimeOut))
                {
                    return(IPCDispatchResult.Timeout);
                }
            } finally {
                RemotingServices.Disconnect(message);
            }
            return(IPCDispatchResult.Success);
        }
        internal virtual IPCDispatchResult DoDispatchSyncMessage(IPCBaseSyncMessage message, IPCBaseMessagesQueue receaverQueue)
        {
            // ensure that IPC server is alive
            if (!ChannelServices.RegisteredChannels.Any(i => i.ChannelName == _dispatcherID.Value)) {
                serverChannel = new IpcServerChannel(_dispatcherID.Value, _dispatcherID.Value);
                if (!ChannelServices.RegisteredChannels.Any(i => i == serverChannel)) {
                    ChannelServices.RegisterChannel(serverChannel, false);
                }
            }

            // share object
            RemotingServices.Marshal(message,
                message.UriSuffix,
                message.GetType());
            try {
                // notify receaver
                IIPCGUID helperID = new IPCGUID(message.GetHashCode());
                IPCSyncHelperMessage helperMessage = new IPCSyncHelperMessage(new IPCUri(_dispatcherID, message).Value, message.GetType(), helperID);
                helperMessage.DispatherID = _dispatcherID;
                message.DispatherID = _dispatcherID;
                receaverQueue.EnqueueMessage(helperMessage);
                _receaverWaitHandle.Set();
                if (!_dispatcherWaitHandle.WaitOne(message.TimeOut))
                    return IPCDispatchResult.Timeout;
            } finally {
                RemotingServices.Disconnect(message);
            }
            return IPCDispatchResult.Success;
        }
 internal virtual IPCDispatchResult DoDispatchAsyncMessage(IPCBaseAsyncMessage message, IPCBaseMessagesQueue receaverQueue)
 {
     _receaverQueue.EnqueueMessage(message);
     _receaverWaitHandle.Set();
     return(IPCDispatchResult.Success);
 }