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


C# Subject.Wait方法代码示例

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


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

示例1: Wait

        public void Wait()
        {
            var subject = new Subject<int>();

            Task.Run(async () =>
            {
                await Task.Delay(TimeSpan.FromSeconds(1));
                subject.OnNext(100);
                subject.OnCompleted();
            });

            subject.Wait().Is(100);
        }
开发者ID:gameserver,项目名称:UniRx,代码行数:13,代码来源:ObservableTest.cs

示例2: Wait

        public void Wait()
        {
#if !UNITY_METRO

            var subject = new Subject<int>();

            ThreadPool.QueueUserWorkItem(_ =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
                subject.OnNext(100);
                subject.OnCompleted();
            });

            subject.Wait().Is(100);

#endif
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:17,代码来源:ObservableTest.cs

示例3: Wait

        public void Wait()
        {
            SetScehdulerForImport();
#if !UNITY_METRO
            var subject = new Subject<int>();
            ThreadPool.QueueUserWorkItem(_ =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
                subject.OnNext(100);
                subject.OnCompleted();
            });
            subject.Wait().Is(100);
#endif
            UniRx.Scheduler.SetDefaultForUnity();
        }
开发者ID:neuecc,项目名称:UniRx,代码行数:15,代码来源:TestImporter.cs

示例4: Request

        public void Request(Uri uri)
        {
            Console.WriteLine("############################################################");

            // request
            var request = new HttpRequest(uri);
            request.EnableEncoding();
            request.SetKeepAlive(true);
            Console.Write(request.ToString());

#if USE_BYTES_BODY
            using (var subject = new ChunkedHttpResponseObserver())
            {
                var body = new Subject<IList<Byte>>();
                body.Subscribe(x =>
                {
                    Console.WriteLine("body: " + x.Count + " bytes");
                }
                , ex =>
                {
                    Console.WriteLine(ex);
                }
                , () =>
                {
                    Console.WriteLine("body end");
                });
                subject.BodyObservable.Subscribe(body);

                bool keepAlive = true;
                subject.KeepAliveObservalbe
                    .Subscribe(x =>
                    {
                        // disconnect
                        keepAlive = x;
                    });
#else
            using (var subject = new HttpRawByteSubject())
            {
                var body = new Subject<Byte>();
                var buffer = new List<Byte>();
                body.Subscribe(x =>
                {
                    buffer.Add(x);
                }
                , ex =>
                {
                    Console.WriteLine(ex);
                }
                , () =>
                {
                    Console.WriteLine("body: " + buffer.Count + " bytes");
                    Console.WriteLine("body end");
                });
                subject.BodyObservable.Subscribe(body);
#endif

                // statusline
                subject.StatusObservable.Subscribe(x =>
                {
                    Console.WriteLine("status: " + x);
                });

                // response headers
                subject.HeaderObservable.Subscribe(x =>
                {
                    Console.WriteLine(x.Key + ": " + x.Value);
                }
                , () =>
                {
                    Console.WriteLine();
                }
                );

                ////////////////////////////
                // connect
                ////////////////////////////
                GetConnection(uri)
                    .Subscribe(x =>
                    {
                        // ready to read
                        subject.OnNext(x);

                        // send request
                        x.SendRequestObservable(request)
                        .Subscribe(_ =>
                        {

                        });
                    }
                    , subject.OnError
                    )
                    ;

                // wait...
                body.Wait();

                if (!keepAlive)
                {
                    Close();
                }
//.........这里部分代码省略.........
开发者ID:ousttrue,项目名称:ReactiveWeb,代码行数:101,代码来源:Program.cs


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