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


C# CompositeDisposable.Dispose方法代码示例

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


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

示例1: AddAfterDisposal

        public void AddAfterDisposal()
        {
            int i1 = 0, i2 = 0;
            var d = new CompositeDisposable ();
            d.Add (Disposable.Create (() => i1++));
            d.Dispose ();
            Assert.AreEqual (1, i1, "#1");
            d.Dispose ();
            Assert.AreEqual (1, i1, "#2"); // no further addition

            d.Add (Disposable.Create (() => i2++));
            Assert.AreEqual (1, i2, "#3");
            d.Dispose ();
            Assert.AreEqual (1, i2, "#4"); // no further addition

            d.Add (Disposable.Create (() => i2++)); // should be immediately disposed
            Assert.AreEqual (2, i2, "#5");
        }
开发者ID:jorik041,项目名称:mono-reactive,代码行数:18,代码来源:CompositeDisposableTest.cs

示例2: DisposeTest

        public void DisposeTest()
        {
            var disposes = new CompositeDisposable();
            var dis1 = new DisposeObject1();
           
            disposes.Dispose();
         

            disposes.AddDisposable(new DisposeObject1());
        }
开发者ID:netcasewqs,项目名称:nlite,代码行数:10,代码来源:CompositeDisposableObjectTest.cs

示例3: ShowView

			public IDisposable ShowView(FrameworkElement view) {
				var disp = new CompositeDisposable();
				disp.Add(scheduler.Schedule(() => {
					disp.Add(showView(view));
				}));
				return Disposable.Create(() => {
					scheduler.Schedule(() => {
						disp.Dispose();
					});
				});
			}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:11,代码来源:ViewPresenter.cs

示例4: AddTwice

 public void AddTwice()
 {
     int i = 0;
     var d = new CompositeDisposable ();
     var item = Disposable.Create (() => i++);
     d.Add (item);
     d.Add (item);
     // this results in two items registered.
     Assert.AreEqual (2, d.Count, "#1");
     d.Dispose ();
     // though, since the first disposal takes effect, it never invokes Dispose() on item twice.
     Assert.AreEqual (1, i, "#2");
 }
开发者ID:jorik041,项目名称:mono-reactive,代码行数:13,代码来源:CompositeDisposableTest.cs

示例5: when_Dispose_is_called_then_added_IDisposable_is_disposed

        public void when_Dispose_is_called_then_added_IDisposable_is_disposed()
        {
            var disposables = new CompositeDisposable();

            var eventWasFired = false;

            var disposable = AnonymousDisposable.Create(() => eventWasFired = true);
            disposables.Add(disposable);

            Assert.That(eventWasFired, Is.False);

            disposables.Dispose();

            Assert.That(eventWasFired, Is.True);
        }
开发者ID:ganesum,项目名称:Blitz,代码行数:15,代码来源:CompositeDisposableTests.cs

示例6: Awake

    public override void Awake()
    {
        var app = AppController.Instance;
        this.coinNumberText.text = string.Format("{0:000}", app.Coin);
        this.damageNumberText.text = string.Format("{0:000}", app.Damage);
        this.usedInkNumberText.text = string.Format("{0:000}", app.UsedInk);

        var resources = new CompositeDisposable();
        // startAction function
        // return Action<Vector3, IObservable<Vector3>>
        // paras: before = MouseDownStream, stream == MouseUpStream
        Action<Vector3, IObservable<Vector3>> startAction = (before, stream) =>
        {
            // after == Drag.MouseUpStream
            stream.First()
                .Subscribe(after =>
                {
                    if (Vector3.Distance(before, after) <= 0.3f)
                    {
                        resources.Dispose();
                        Application.LoadLevel("Title");
                    }
                });
        };

        Drag.MouseDownStream()
            .Subscribe(before =>
            {
                startAction(before, Drag.MouseUpStream());
            })
            .AddTo(resources);

        Drag.TouchStartStream()
            .Subscribe(beforeTouch =>
            {
                var before = Camera.main.ScreenToWorldPoint(beforeTouch.Item1.position);
                startAction(before,
                            Drag.TouchUpStream(beforeTouch.Item1.fingerId)
                                .Select(touch => Camera.main.ScreenToWorldPoint(touch.Item1.position)));
            })
            .AddTo(resources);

        base.Awake();
    }
开发者ID:Lisy09Personal,项目名称:UnityChanRoadRx,代码行数:44,代码来源:ResultController.cs

示例7: Test

        public void Test()
        {
            var disposes = new CompositeDisposable();
            var dis1 = new DisposeObject1();
            var dis2 = new DisposeObject2();

            Assert.IsFalse(disposes.IsDisposed);
            Assert.IsFalse(dis1.IsDisposed);
            Assert.IsFalse(dis2.IsDisposed);

            disposes.AddDisposable(dis1);
            disposes.AddDisposable(dis2);

            disposes.Dispose();
            Assert.IsTrue(disposes.IsDisposed);
            Assert.IsTrue(dis1.IsDisposed);
            Assert.IsTrue(dis2.IsDisposed);

          


        }
开发者ID:netcasewqs,项目名称:nlite,代码行数:22,代码来源:CompositeDisposableObjectTest.cs

示例8: MainForm

        public MainForm()
        {
            InitializeComponent();
              components = new NestedContainer(this);

              var uiThread = new SynchronizationContextScheduler(SynchronizationContext.Current);

              var subscriptions = new CompositeDisposable(
            RxMessageBrokerMinimod.Default.Register<Log>(m =>
            {
              Debug.WriteLine(m.Message);

              var addedIndex = lbxEvents.Items.Add(m.Message);
              lbxEvents.SelectedIndex = addedIndex;
            }, uiThread),
            RxMessageBrokerMinimod.Default.Register<CurrentFile>(m =>
            {
              lblCurrentFile.Text = m.FileName;
              lblLength.Text = m.Length.ToString();
            }, uiThread));

              components.Add(new Disposer(_ => subscriptions.Dispose()));
        }
开发者ID:agross,项目名称:mpc-deleter,代码行数:23,代码来源:MainForm.cs

示例9: BridgeTo

        public async Task BridgeTo(string destination, BridgeOptions options, Action<EventMessage> onProgress = null)
        {
            if (!IsAnswered && !IsPreAnswered)
            {
                return;
            }

            Log.Debug(() => "Channel {0} is attempting a bridge to {1}".Fmt(UUID, destination));

            if (string.IsNullOrEmpty(options.UUID))
            {
                options.UUID = Guid.NewGuid().ToString();
            }

            var subscriptions = new CompositeDisposable();

            subscriptions.Add(
                eventSocket.Events.Where(x => x.UUID == options.UUID)
                    .Take(1)
                    .Subscribe(x => Bridge = new BridgeStatus(false, "In Progress", new BridgedChannel(x, eventSocket))));

            if (onProgress != null)
            {
                subscriptions.Add(
                    eventSocket.Events.Where(x => x.UUID == options.UUID && x.EventName == EventName.ChannelProgress)
                        .Take(1)
                        .Subscribe(onProgress));
            }

            var result = await eventSocket.Bridge(UUID, destination, options).ConfigureAwait(false);

            Log.Debug(() => "Channel {0} bridge complete {1} {2}".Fmt(UUID, result.Success, result.ResponseText));
            subscriptions.Dispose();

            Bridge = new BridgeStatus(result.Success, result.ResponseText, Bridge.Channel);
        }
开发者ID:bushadam,项目名称:NEventSocket,代码行数:36,代码来源:Channel.cs

示例10: CountAndDispose

 public void CountAndDispose()
 {
     var d = new CompositeDisposable (Disposable.Empty);
     Assert.AreEqual (1, d.Count, "#1");
     d.Dispose ();
     Assert.AreEqual (0, d.Count, "#2");
 }
开发者ID:jorik041,项目名称:mono-reactive,代码行数:7,代码来源:CompositeDisposableTest.cs

示例11: PhoneApplicationPage_Loaded

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            additionallocalization_images = new CompositeDisposable(clear_additional_locs());

            var s = new CompositeDisposable(additionallocalization_images as IDisposable);

            var image_obs = VM.ObservableForProperty(x => x.MapImage).Value()              
                .StartWith(VM.MapImage).Where(img => img != null);



            s.Add(image_obs.Subscribe(img => { ImgZoom.Source = img; }));


            _currentPos = new RelativeLocationBinding(currentPosImg, update_transform, VM.ObservableForProperty(x => x.CurrentLocation).Value().StartWith(VM.CurrentLocation).Select(ScaleToImage));
            s.Add(_currentPos);

            _currentLoc = new RelativeLocationBinding(currentLocalizationImg, update_transform, VM.ObservableForProperty(x => x.PrimaryLocalization).Value().StartWith(VM.PrimaryLocalization).Select(ScaleToImage));
            s.Add(_currentLoc);

            s.Add(
                VM.AdditionalLocalizations
                .ObserveOnDispatcher()
                .Do(_ => additionallocalization_images.Dispose())
                .SelectMany(p => p)
                .ObserveOnDispatcher()
                .Subscribe(p =>
                    {                        
                        var it = ScaleToImage(p);
                        var source = this.Resources["GPSPointImage"] as BitmapImage;
                        if(source != null)
                        {
                            var img = new Image() { Source = source, Height = source.PixelHeight, Width = source.PixelWidth };
                            var binding = new RelativeLocationBinding(img, update_transform) { RelativeLocation = it };
                            additionallocalization_images.Add(binding);
                            MainCanvas.Children.Add(img);
                        }
                    }));

            subscriptions = s;
        }
开发者ID:rollingthunder,项目名称:DiversityMobile,代码行数:41,代码来源:ViewMap.xaml.cs

示例12: WhenLoaded

        /// <summary>
        ///     Requests loading the image of <paramref name="size"/> located on <paramref name="uri"/>. 
        /// </summary>
        /// <param name="uri">
        ///     An uri of the image to load.
        /// </param>
        /// <param name="size">
        ///     The desired size of the image.
        /// </param>
        /// <param name="minSize">
        ///     Thi mimimum accetable size. 
        /// </param>
        /// <returns>
        ///     Returns an observable sequence which contains an image(s) of <paramref name="size"/> loaded using <paramref name="uri"/>.
        /// </returns>
        /// <remarks>
        ///     If the image cannot be loaded or loaded image has smaller size than requested, then it tries to load the image using fallback
        ///     <see cref="BaseImageLoader"/>. All intermediate images (the images of smaller size than requested), are pushed into observable sequence.
        /// </remarks>
        protected IObservable<ImageInfo> WhenLoaded(Uri uri, Size size, Size minSize)
        {
            var result = Observable.Create<ImageInfo>(observer =>
                {
                    ImageInfo image = null;
                    var compositeDisposable = new CompositeDisposable();

                    compositeDisposable.Add(this.WhenLoadedInternal(uri, size).Subscribe(
                        img =>
                        {
                            observer.OnNext(img);
                            image = img;
                        },
                        err =>
                        {
                            if (fallbackLoader != null)
                            {
                                compositeDisposable.Add(this.fallbackLoader.WhenLoaded(uri, size, minSize)
                                    .Do(this.OnFallbackImageLoaded)
                                    .Subscribe(observer));
                            }
                            else
                            {
                                observer.OnError(err);
                            }
                        },
                        () =>
                        {
                            if ((image == null || image.IsFittedIn(size) == false || image.ForceFallback) && fallbackLoader != null)
                            {
                                compositeDisposable.Add(this.fallbackLoader.WhenLoaded(uri, size, image == null ? minSize : image.Size)
                                    .Do(this.OnFallbackImageLoaded)
                                    .Subscribe(observer));
                            }
                            else
                            {
                                observer.OnCompleted();
                            }
                        }));

                    return () => { compositeDisposable.Dispose(); };
                });

            return result;
        }
开发者ID:mdabbagh88,项目名称:UniversalImageLoader,代码行数:64,代码来源:BaseImageLoader.cs

示例13: SetupCommand

 static void SetupCommand(TaskCompletionSource<bool?> tcs, ReactiveCommand<bool?> command) {
     var d = new CompositeDisposable {command};
     d.Add(command.ThrownExceptions.Subscribe(x => {
         tcs.SetException(x);
         d.Dispose();
     }));
     d.Add(command.Subscribe(x => {
         tcs.SetResult(x);
         d.Dispose();
     }));
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:11,代码来源:WpfDialogManager.cs


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