当前位置: 首页>>代码示例>>C#>>正文


C# ISubject.OnNext方法代码示例

本文整理汇总了C#中ISubject.OnNext方法的典型用法代码示例。如果您正苦于以下问题:C# ISubject.OnNext方法的具体用法?C# ISubject.OnNext怎么用?C# ISubject.OnNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISubject的用法示例。


在下文中一共展示了ISubject.OnNext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: YieldObservable

        public void YieldObservable()
        {
            coroutine = YieldObservableBlock().AsCoroutine<object>();

            subject = new Subject<object>();

            Subscribe();

            expectedResults.Add(t1);
            expectedResults.Add(t2);

            AssertExpectedResults();

            subject.OnNext(t3);

            // don't want to include results from observables yielded
            //expectedResults.Add(t3);

            AssertExpectedResults();

            subject.OnCompleted();

            expectedResults.Add(t4);

            AssertExpectedResults();
            AssertExpectedErrors();
            AssertCompleted();
        }
开发者ID:nithinphilips,项目名称:bbwifimusicsync,代码行数:28,代码来源:CoroutineTests.cs

示例2: DefaultServerBroker

        public DefaultServerBroker(IStorage storage)
        {
            _storage = storage;

            _offRecieverThreadSubject = new Subject<IMessage>();
            _offRecieverThreadInternalSubject = new Subject<IMessage>();

            OffRecieverThread = new ServerBrokerObservations(_offRecieverThreadSubject);

            // ensure off-request data is observed onto a different thread
            _offRecieverThreadInternalSubject.Subscribe(payload => Observable.Start(() => _offRecieverThreadSubject.OnNext(payload), TaskPoolScheduler.Default));
        }
开发者ID:mike-kaufman,项目名称:Glimpse.Prototype,代码行数:12,代码来源:DefaultServerBroker.cs

示例3: MessageStreamResource

        public MessageStreamResource(IServerBroker serverBroker)
        {
            _serverBroker = serverBroker;

            _senderSubject = new Subject<Container>();

            // setup heart beat to keep alive client connections
            Observable.Interval(new TimeSpan(0, 0, 20), TaskPoolScheduler.Default).Subscribe(x => _senderSubject.OnNext(Container.Ping()));
            
            // TODO: See if we can get Defered working there
            // lets subscribe, hope of the thread and then broadcast to all connections
            //_serverBroker.OffRecieverThread.ListenAll().Subscribe(message => Observable.Defer(() => Observable.Start(() => ProcessMessage(message), TaskPoolScheduler.Default)));
            _serverBroker.OffRecieverThread.ListenAll().Subscribe(message => Observable.Start(() => ProcessMessage(message), TaskPoolScheduler.Default));
        }
开发者ID:mike-kaufman,项目名称:Glimpse.Prototype,代码行数:14,代码来源:MessageStreamResource.cs

示例4: Connection

        public Connection(string address, string username)
        {
            _statusStream = new BehaviorSubject<ConnectionInfo>(new ConnectionInfo(ConnectionStatus.Uninitialized, address));
            Address = address;
            _hubConnection = new HubConnection(address);
            _hubConnection.Headers.Add(ServiceConstants.Server.UsernameHeader, username);
            CreateStatus().Subscribe(
                s => _statusStream.OnNext(new ConnectionInfo(s, address)),
                _statusStream.OnError,
                _statusStream.OnCompleted);
            _hubConnection.Error += exception => Log.Error("There was a connection error with " + address, exception);

            BlotterHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.BlotterHub);
            ExecutionHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.ExecutionHub);
            PricingHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.PricingHub);
            ReferenceDataHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.ReferenceDataHub);
        }
开发者ID:kowalgta,项目名称:ReactiveTrader,代码行数:17,代码来源:Connection.cs

示例5: Connection

        public Connection(string address, string username)
        {
            _statusStream = new BehaviorSubject<ConnectionInfo>(
                new ConnectionInfo(ConnectionStatus.Uninitialized, address));
            Address = address;
            hubConnection = new HubConnection(address);
            //hubConnection.Headers.Add(ServiceConstants.Server.UsernameHeader, username);
            CreateStatus().Subscribe(
                s => _statusStream.OnNext(new ConnectionInfo(s, address)),
                _statusStream.OnError,
                _statusStream.OnCompleted);
            hubConnection.Error += exception => log.Error("There was a connection error with " 
                + address, exception);

            TickerHubProxy = hubConnection.CreateHubProxy(ServiceConstants.Server.TickerHub);

        }
开发者ID:Jurabek,项目名称:SignalrRxDemo,代码行数:17,代码来源:Connection.cs

示例6: DefaultAgentBroker

        public DefaultAgentBroker(IMessagePublisher messagePublisher, IMessageConverter messageConverter, IContextData<MessageContext> context)
        {
            _messagePublisher = messagePublisher;
            _messageConverter = messageConverter;
            _context = context;

            _onSenderThreadSubject = new Subject<AgentBrokerPayload>();
            _offSenderThreadSubject = new Subject<AgentBrokerPayload>();
            _offSenderThreadInternalSubject = new Subject<AgentBrokerPayload>();
            _publisherInternalSubject = new Subject<AgentBrokerPayload>();

            OnSenderThread = new AgentBrokerObservations(_onSenderThreadSubject);
            OffSenderThread = new AgentBrokerObservations(_offSenderThreadSubject);

            // ensure off-request data is observed onto a different thread
            _offSenderThreadInternalSubject.Subscribe(payload => Observable.Start(() => _offSenderThreadSubject.OnNext(payload), TaskPoolScheduler.Default));
            _publisherInternalSubject.Subscribe(x => Observable.Start(() => PublishMessage(x), TaskPoolScheduler.Default));
        }
开发者ID:mike-kaufman,项目名称:Glimpse.Prototype,代码行数:18,代码来源:DefaultAgentBroker.cs

示例7: YieldObserableError

        public void YieldObserableError()
        {
            coroutine = YieldObservableErrorBlock().AsCoroutine<object>();

            subject = new Subject<object>();

            Subscribe();

            subject.OnNext(t2);
            subject.OnError(e1);

            expectedResults.Add(t1);
            //expectedResults.Add(t2);
            expectedErrors.Add(e1);

            AssertExpectedResults();
            AssertExpectedErrors();
            AssertNotCompleted();
        }
开发者ID:nithinphilips,项目名称:bbwifimusicsync,代码行数:19,代码来源:CoroutineTests.cs

示例8: StartReportingProgress

        protected virtual IDisposable StartReportingProgress(Aria2cClientEventArgs args, Func<Aria2cClientEventArgs, Aria2cClientEventArgs> getProgress, Action<Aria2cClientEventArgs> completed, ISubject<Aria2cClientEventArgs> subject)
        {
            _logger.Info("Observando progresso de {0}.", args.Status.Gid);

            ThreadPoolScheduler scheduler = Scheduler.ThreadPool;

            Action<Action> work = self =>
                {
                    try
                    {
                        Aria2cClientEventArgs eventArgs = getProgress(args);

                        if (eventArgs.Status.Completed)
                        {
                            completed(eventArgs);
                            return;
                        }
                        subject.OnNext(eventArgs);
                    }
                    catch (Aria2cException aex)
                    {
                        _logger.DebugException(aex.Message, aex);
                        subject.OnError(aex);
                        return;
                    }

                    Thread.Sleep(1000);
                    self();
                };

            return scheduler.Schedule(work);
        }
开发者ID:kibiluzbad,项目名称:aria4net,代码行数:32,代码来源:Aria2cWebSocketWatcher.cs

示例9: MessageBroker

        public MessageBroker(IMessagePublisher messagePublisher)
        {
            _messagePublisher = messagePublisher;

            _onRequestThreadSubject = new Subject<Message>();
            _offRequestThreadSubject = new Subject<Message>();
            _offRequestThreadInternalSubject = new Subject<Message>();
            _publisherInternalSubject = new Subject<Message>();

            // ensure off-request data is observed onto a different thread
            _offRequestThreadInternalSubject.Subscribe(x => Observable.Start(() => _offRequestThreadSubject.OnNext(x), TaskPoolScheduler.Default));
            _publisherInternalSubject.Subscribe(x => Observable.Start(() => _messagePublisher.Publish(x), TaskPoolScheduler.Default));
        }
开发者ID:avanderhoorn,项目名称:MessageWorkers,代码行数:13,代码来源:Program.cs


注:本文中的ISubject.OnNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。