diff options
-rw-r--r-- | Ryujinx.Common/ReactiveObject.cs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Ryujinx.Common/ReactiveObject.cs b/Ryujinx.Common/ReactiveObject.cs index be30e9b2..8495c78f 100644 --- a/Ryujinx.Common/ReactiveObject.cs +++ b/Ryujinx.Common/ReactiveObject.cs @@ -6,7 +6,8 @@ namespace Ryujinx.Common public class ReactiveObject<T> { private ReaderWriterLock _readerWriterLock = new ReaderWriterLock(); - private T _value; + private bool _isInitialized = false; + private T _value; public event EventHandler<ReactiveEventArgs<T>> Event; @@ -25,12 +26,15 @@ namespace Ryujinx.Common _readerWriterLock.AcquireWriterLock(Timeout.Infinite); T oldValue = _value; - - _value = value; + + bool oldIsInitialized = _isInitialized; + + _isInitialized = true; + _value = value; _readerWriterLock.ReleaseWriterLock(); - if (oldValue == null || !oldValue.Equals(_value)) + if (!oldIsInitialized || !oldValue.Equals(_value)) { Event?.Invoke(this, new ReactiveEventArgs<T>(oldValue, value)); } |