本文整理汇总了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, _ => { });
}
示例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"};
}