示例#1
0
 internal void Dispose(TimeSpan CloseTimeout)
 {
     if (_host != null)
     {
         _operationPending.WaitOne(CloseTimeout);
         _host.Dispose();
         _host = null;
     }
 }
 internal void Dispose(TimeSpan CloseTimeout)
 {
     if (_host != null)
     {
         _operationPending.WaitOne(CloseTimeout);
         _host.Dispose();
         _host = null;
     }
 }
示例#3
0
        internal void Open(ConcurrencyMode concurrency)
        {
            _concurrency = concurrency;
            //Action open = delegate
            {
                try
                {
                    if (_host == null)
                    {
                        RpcExecuteHandler onExecute =
                            delegate(IRpcCallInfo client, byte[] arg)
                        {
                            if (_concurrency == ConcurrencyMode.Single)
                            {
                                //lock (this)
                                //{
                                _operationPending.Reset();
                                try
                                {
                                    return(Invoke(client, _endpoint._contractType, arg));
                                }
                                finally
                                {
                                    _operationPending.Set();
                                }
                                //}
                            }
                            if (_concurrency == ConcurrencyMode.Multiple)
                            {
                                //BUG: need have collection of operations because second operation rewrites state of first
                                _operationPending.Reset();
                                try
                                {
                                    return(Invoke(client, _endpoint._contractType, arg));
                                }
                                finally
                                {
                                    _operationPending.Set();
                                }
                            }

                            throw new NotImplementedException(
                                      string.Format("ConcurrencyMode {0} is note implemented", _concurrency));
                        };
                        _host = RpcRequestReplyChannelFactory.CreateHost(_endpoint._binding, _endpoint._address, _endpoint._uuid);


                        _host.OnExecute += onExecute;
                        _host.StartListening();
                    }
                    //_opened.Set();
                }
                catch (Exception ex)
                {
                    bool handled = ExceptionHandler.AlwaysHandle.HandleException(ex);
                    if (!handled)
                    {
                        throw;
                    }
                }
            };
            //Tasks.Factory.StartNew(open);
            //_opened.WaitOne();
        }
        internal void Open(ConcurrencyMode concurrency)
        {
            _concurrency = concurrency;
            //Action open = delegate
            {
                try
                {
                    if (_host == null)
                    {
                        RpcExecuteHandler onExecute =
                            delegate(IRpcCallInfo client, byte[] arg)
                            {
                                if (_concurrency == ConcurrencyMode.Single)
                                {
                                    //lock (this)
                                    //{
                                    _operationPending.Reset();
                                    try
                                    {
                                        return Invoke(client, _endpoint._contractType, arg);
                                    }
                                    finally
                                    {
                                        _operationPending.Set();
                                    }
                                    //}
                                }
                                if (_concurrency == ConcurrencyMode.Multiple)
                                {
                                    //BUG: need have collection of operations because second operation rewrites state of first
                                    _operationPending.Reset();
                                    try
                                    {
                                        return Invoke(client, _endpoint._contractType, arg);
                                    }
                                    finally
                                    {
                                        _operationPending.Set();
                                    }
                                }

                                throw new NotImplementedException(
                                    string.Format("ConcurrencyMode {0} is note implemented", _concurrency));
                            };
                        _host = RpcRequestReplyChannelFactory.CreateHost(_endpoint._binding, _endpoint._address, _endpoint._uuid);

                        _host.OnExecute += onExecute;
                        _host.StartListening();
                    }
                    //_opened.Set();
                }
                catch (Exception ex)
                {
                    bool handled = ExceptionHandler.AlwaysHandle.HandleException(ex);
                    if (!handled) throw;
                }
            };
            //Tasks.Factory.StartNew(open);
            //_opened.WaitOne();
        }