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


C# Subject.Zip方法代码示例

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


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

示例1: Zip

        public void Zip()
        {
            var a = new Subject<int>();
            var b = new Subject<int>();

            a.OnNext(10);
            b.OnNext(20);

            var l = Enumerable.Empty<Unit>().Select(_ => Notification.CreateOnNext(new { x = 0, y = 0 })).ToList();
            a.Zip(b, (x, y) => new { x, y }).Materialize().Subscribe(x => l.Add(x));

            a.OnNext(1000);
            b.OnNext(2000);

            a.OnCompleted();

            l.Count.Is(1); // OnNext

            a.OnNext(1001);
            l.Count.Is(1);

            b.OnNext(5);
            l.Count.Is(2); // Completed!

            l[1].Kind.Is(NotificationKind.OnCompleted);
        }
开发者ID:gameserver,项目名称:UniRx,代码行数:26,代码来源:Observable.ConcatTest.cs

示例2: Main

    protected override void Main()
    {
      TraceLine(Instructions.PressAnyKeyToCancel);

      var queries = new Subject<IObservable<string>>();

      var zipped = queries
        .Zip()
        .Select(list => list.Aggregate(string.Empty, (acc, cur) => acc += cur + " "))
        .Take(3);

      using (zipped.Subscribe(ConsoleOutput))
      {
        var xs = Observable.Interval(TimeSpan.FromSeconds(.5));
        var ys = Observable.Interval(TimeSpan.FromSeconds(1));
        var zs = Observable.Interval(TimeSpan.FromSeconds(1.5));

        queries.OnNext(xs.Select(value => Text.First + ' ' + value));
        queries.OnNext(ys.Select(value => Text.Second + ' ' + value));
        queries.OnNext(zs.Select(value => Text.Third + ' ' + value));
        queries.OnCompleted();

        WaitForKey();
      }
    }
开发者ID:ibebbs,项目名称:Rxx,代码行数:25,代码来源:ZipLab.cs

示例3: Zip2

 public void Zip2()
 {
     SetScehdulerForImport();
     var a = new Subject<int>();
     var b = new Subject<int>();
     a.OnNext(10);
     b.OnNext(20);
     var l = Enumerable.Empty<Unit>().Select(_ => Notification.CreateOnNext(new { x = 0, y = 0 })).ToList();
     a.Zip(b, (x, y) => new { x, y }).Materialize().Subscribe(x => l.Add(x));
     a.OnNext(1000);
     b.OnNext(2000);
     a.OnCompleted();
     l.Count.Is(1); // OnNext
     b.OnCompleted(); // Completed!
     l.Count.Is(2); // Completed!
     l[1].Kind.Is(NotificationKind.OnCompleted);
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:18,代码来源:TestImporter.cs

示例4: ScanDirectoryAsync

        private async Task ScanDirectoryAsync(StorageFolder storageFolder, bool doSha1, IObserver<string> starts, IObserver<FileInfo> completes)
        {
            foreach (var entry in await storageFolder.GetItemsAsync()) {
                var folder = entry as StorageFolder; // folder
                if (folder != null) {
                    starts.OnNext(folder.Name);

                    var innerStarts = new Subject<string>();
                    var innerCompletes = new Subject<FileInfo>();
                    var _ = Task.Run(() => ScanDirectoryAsync(folder, false, innerStarts, innerCompletes));

                    var totalSize = await innerStarts
                        .Zip(innerCompletes, (s, f) => (double)f.Size)
                        .Sum(x => x).FirstAsync();

                    completes.OnNext(new FileInfo { Name = folder.Name, Size = (ulong)totalSize });
                }

                var file = entry as StorageFile; // file
                if (file != null) {
                    starts.OnNext(file.Name);
                    var fileInfo = await ScanFile(file, doSha1).ConfigureAwait(false);
                    completes.OnNext(fileInfo);
                }
            }
            starts.OnCompleted();
            completes.OnCompleted();
        }
开发者ID:Porges,项目名称:Ignite2015,代码行数:28,代码来源:MainPage.xaml.cs

示例5: StartProcessing

        private void StartProcessing()
        {
            if (IsKinectPaused)
            {
                IsKinectPaused = false;
            }

            var observableColorAndDepth = Observable.FromEventPattern<MultiSourceFrameArrivedEventArgs>(KinectManager.Instance, "ColorAndDepthSourceFrameArrived");

            ColorAndDepthSourceSubscription = observableColorAndDepth
                .Do(_ =>
                {
                    ++totalColorAndDepthFrames;
                    ++colorAndDepthFrames;

                    if (colorAndDepthFPSTimer.ElapsedMilliseconds >= 1000)
                    {
                        ColorAndDepthFramesPerSec = colorAndDepthFrames;
                        colorAndDepthFrames = 0;
                        colorAndDepthFPSTimer.Restart();
                    }
                })
                .ObserveOn(NewThreadScheduler.Default)
                .Subscribe(
                e => ColorAndDepthSourceFrameArrived(e.Sender, e.EventArgs)
            );

            observableColorData = new Subject<byte[]>();
            observableDepthData = new Subject<ushort[]>();
            observableDepthSpaceData = new Subject<DepthSpacePoint[]>();

            // -- Set up Automatic thresholding --

            var ExecuteAutomaticThreshold = ReactiveCommand.CreateAsyncTask(param =>
            {
                var input = param as ushort[];

                return AutomaticThreshold(input);
            });

            AutoThresholdSubscription = observableDepthData
                .Sample(TimeSpan.FromSeconds(1))
                .Where(_ => AutomaticThresholds)
                .InvokeCommand(ExecuteAutomaticThreshold);

            ExecuteAutomaticThreshold
                .Subscribe((t) =>
                {
                    FarThreshold = t;
                    NearThreshold = t - 500; // Nearthreshold is 50 cm towards the camera.
                });

            // --
            // -- Set up Filtering --

            FilterFramesSubscription = observableColorData
                .Zip(observableDepthData, observableDepthSpaceData, (c, d, dsp) => Tuple.Create(c, d, dsp))
                .InvokeCommand(ExecuteFilterVideoFrame);

            // --
        }
开发者ID:jtpgames,项目名称:Kinect-Recorder,代码行数:61,代码来源:FilterKinectViewModel.cs


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