public void RegisterSessionHandler(Type handlerType, SessionHandlerOptions options)
        {
            IMessageSessionAsyncHandlerFactory messageSessionAsyncHandlerFactory = MessageSessionHandlerFactory.Create(handlerType);

            MessageSessionPumpHost.RegisterSessionHandlerFactoryAsyncResult registerSessionHandlerFactoryAsyncResult = new MessageSessionPumpHost.RegisterSessionHandlerFactoryAsyncResult(this, messageSessionAsyncHandlerFactory, options, null, null);
            registerSessionHandlerFactoryAsyncResult.RunSynchronously();
        }
        private IAsyncResult BeginRegisterSessionHandler(Type handlerType, SessionHandlerOptions options, AsyncCallback callback, object state)
        {
            IMessageSessionAsyncHandlerFactory messageSessionAsyncHandlerFactory = MessageSessionHandlerFactory.Create(handlerType);

            return((new MessageSessionPumpHost.RegisterSessionHandlerFactoryAsyncResult(this, messageSessionAsyncHandlerFactory, options, callback, state)).Start());
        }
        public Task RegisterSessionHandlerFactoryAsync(IMessageSessionHandlerFactory factory, SessionHandlerOptions options)
        {
            IMessageSessionAsyncHandlerFactory messageSessionAsyncHandlerFactory = MessageSessionHandlerFactory.Create(factory);

            return(TaskHelpers.CreateTask((AsyncCallback c, object s) => this.BeginRegisterSessionHandler(messageSessionAsyncHandlerFactory, options, c, s), (IAsyncResult r) => this.EndRegisterSessionHandler(r)));
        }