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


C# Subject.SubscribeOn方法代码示例

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


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

示例1: LoopbackListener

        public LoopbackListener()
        {
            LoopbackDevice.EnsureActive();

            var s = new Subject<Tick>();
            s.SubscribeOn(Scheduler.TaskPool);
            LoopbackDevice.Tickobserver.Where(Filter).Subscribe(s);
            _observer=s;
        }
开发者ID:janderit,项目名称:rocNet0,代码行数:9,代码来源:LoopbackListener.cs

示例2: GrapevineSender

        public GrapevineSender(ZmqContext context, string address, IMessageSerializer serializer)
        {
            _serializer = serializer;
            _scheduler = new EventLoopScheduler();

            _socket = context.CreateSocket(SocketType.PUB);
            _socket.Connect(address);

            _messages = new Subject<ZmqMessage>();
            _messageDispatcher = _messages
                .SubscribeOn(_scheduler)
                .ObserveOn(_scheduler)
                .Subscribe(msg => _socket.SendMessage(msg));
        }
开发者ID:xpando,项目名称:GrapevineZMQ,代码行数:14,代码来源:GrapevineSender.cs

示例3: Main

        static void Main(string[] args)
        {
            byte[] clientArray = new byte[1024];
            IPAddress serverAddress = IPAddress.Parse(ConfigurationManager.AppSettings["serverAddress"]);
            int serverPort = int.Parse(ConfigurationManager.AppSettings["serverPort"]);
            IPEndPoint serverEndPoint = new IPEndPoint(serverAddress, serverPort);

            var task = GetConnectedClient(serverEndPoint);
            task.Wait();

            var client =
                     Observable
                        .Repeat(clientArray)
                        .Consume<byte[], int>(array =>
                            {
                                return task.Result.SendToObservable(array, 0, 1024, SocketFlags.None, serverEndPoint);
                            });
                            
            Subject<long> totalClient = new Subject<long>();
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            var clientDisposable =
                client.SubscribeOn(ThreadPoolScheduler.Instance)
                .ObserveOn(Scheduler.Immediate)
                .Subscribe(x =>
                    {
                        if (x > 0) totalClient.OnNext(x);
                        else totalClient.OnCompleted();
                    });

            var oneMega = 1048576;

            totalClient
                .SubscribeOn(ThreadPoolScheduler.Instance)
                .Window(TimeSpan.FromSeconds(1))
                .Subscribe(x =>
                {
                    x.SubscribeOn(ThreadPoolScheduler.Instance).Aggregate((seed, incr) => seed + incr)
                        .Subscribe(sum => Console.WriteLine("client speed: {0}", sum / oneMega));
                });

            Console.ReadLine();

            stopWatch.Stop();
            clientDisposable.Dispose();

            Console.ReadLine();
        }
开发者ID:NickSGamble,项目名称:RxTests,代码行数:49,代码来源:Program.cs


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