| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="SuspendableBehavior.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.Reactive.Disposables; |
| | | 9 | | using MyNet.Utilities.Suspending; |
| | | 10 | | |
| | | 11 | | namespace MyNet.Observable.Behaviors; |
| | | 12 | | |
| | 444 | 13 | | public abstract class SuspendableBehavior<T>(T owner) : ObservableBehavior<T>(owner), ISuspendable |
| | | 14 | | where T : IObservableObject |
| | | 15 | | { |
| | 444 | 16 | | private readonly Suspender _suspender = new(); |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets a value indicating whether property changed notifications for culture changes are currently suspended. This |
| | | 20 | | /// </summary> |
| | 1683 | 21 | | public bool IsSuspended => _suspender.IsSuspended; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Suspends this behavior until the returned scope is disposed. While suspended, the behavior does not react to pro |
| | | 25 | | /// </summary> |
| | | 26 | | /// <returns>A disposable suspension scope.</returns> |
| | 3 | 27 | | public IDisposable Suspend() => IsDisposed ? Disposable.Empty : _suspender.Suspend(); |
| | | 28 | | } |
| | | 29 | | |