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


C# Subscriber.ObserveOn方法代码示例

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


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

示例1: SerialiseComboBox_SelectedIndexChanged

        void SerialiseComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_subscriber != null) _subscriber.Dispose();

            ISerializer<PstMessage> serializer;
            if (SerialiseComboBox.Text == "DataContract") {
                serializer = new HydraDataContractSerializer<PstMessage>();
            } else {
                serializer = new HydraJsonSerializer<PstMessage>();
            }
            _publisher = new Publisher<PstMessage>(_hydraService, serializer);
            _subscriber = new Subscriber<PstMessage>(_hydraService, serializer);
            _subscriber.ObserveOn(SynchronizationContext.Current).SkipErrors().Subscribe(OnMessage, _ => { });
        }
开发者ID:NorthNick,项目名称:hydra,代码行数:14,代码来源:Form1.cs

示例2: MainFrm

        public MainFrm()
        {
            InitializeComponent();

            WebRequest.DefaultWebProxy = null;
            var pinger = new Pinger(ConfigurationManager.AppSettings["HydraServers"].Split(',').Select(s => s.Trim()));
            pinger.RefreshSync();
            var servers = pinger.ServerInfo.Where(si => si.IsReachable).Select(si => si.Address);

            string pollSetting = ConfigurationManager.AppSettings["PollIntervalMs"];
            int? pollIntervalMs = pollSetting == null ? (int?)null : int.Parse(pollSetting);
            var hydraService = new StdHydraService(new NearestServerProvider(servers, ConfigurationManager.AppSettings["Database"], 5984), new ListenerOptions { PollIntervalMs = pollIntervalMs });

            _dataSubscriber = new Subscriber<StressTestData>(hydraService);
            _dataSubscription = _dataSubscriber.ObserveOn(SynchronizationContext.Current).SkipErrors().Subscribe(OnDataRecv);
            _errorSubscriber = new Subscriber<StressTestError>(hydraService);
            _errorSubscription = _errorSubscriber.ObserveOn(SynchronizationContext.Current).SkipErrors().Subscribe(OnErrorRecv);
            _listener = hydraService.GetListener(new HydraByTopicByDestinationMessageFetcher(typeof(StressTestControl).FullName, "StressTestConsole"));
            _controlSubscription = _listener.ObserveOn(SynchronizationContext.Current).Subscribe(OnControlRecv);
            _controlPublisher = new Publisher<StressTestControl>(hydraService) {ThisParty = "StressTestConsole"};
        }
开发者ID:NorthNick,项目名称:hydra,代码行数:21,代码来源:MainFrm.cs


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