You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for your continued effort in developing and maintaining this MVVM framework.
I have a query regarding the ReactiveUI data persistence functionality, which is described in the guidebook on this page. The context of my query is my FOSS app DateToday, which you can find at this GitHub repository. This app is built with Avalonia and ReactiveUI. Avalonia also provides a brief guide to this data persistence functionality here.
So, I have followed the instructions available in both guides to successfully implement data persistence in my app. One facet of this functionality is AutoSuspendHelper class. I have instantiated this class inside my Application (see: App.axaml.cs, line num. 91).
The compiler raises warning CA2000: 'Dispose objects before losing scope'. The guides I referenced earlier do not address how to handle the disposal of objects of this class.
I would like to resolve this warning. I have taken the following steps to attempt to do so:
If I dispose of this object at the end of the 'if' statement block, the app fails to persist its state to disk. This makes sense to me, because my understanding is that this object needs to be present in memory at the time of data persistence in order to facilitate this feature.
If I inject a reference to this object into the constructor of my primary application window, and add it to my disposables, a new bug occurs in which the the application will crash when the user attempts to close it.
Please note that the same bug occurs if I instead call 'desktop.Shutdown()', where 'desktop' is my 'IApplicationLifetime' implementation. It seems that the disposal of the AutoSuspendHelper object in this fashion prevents the closing of the primary application window.
One possible solution that I am not keen on is to subscribe to the 'IApplicationLifetime' 'Exit' event, and dispose of the AutoSuspendHelper instance in an event handler.
This approach does 'work' in that it demonstrably disposes of the AutoSuspendHelper instance, but it has a number of drawbacks in my opinion, including:
The compiler simply raises a different warning:
I am not convinced, personally, that this event is guaranteed to fire.
Please can you confirm whether it is actually necessary to dispose of this object, and if so, how and when?
Let me know if you would like me to provide additional information.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello all,
Thank you for your continued effort in developing and maintaining this MVVM framework.
I have a query regarding the ReactiveUI data persistence functionality, which is described in the guidebook on this page. The context of my query is my FOSS app DateToday, which you can find at this GitHub repository. This app is built with Avalonia and ReactiveUI. Avalonia also provides a brief guide to this data persistence functionality here.
So, I have followed the instructions available in both guides to successfully implement data persistence in my app. One facet of this functionality is AutoSuspendHelper class. I have instantiated this class inside my Application (see: App.axaml.cs, line num. 91).
The compiler raises warning CA2000: 'Dispose objects before losing scope'. The guides I referenced earlier do not address how to handle the disposal of objects of this class.
I would like to resolve this warning. I have taken the following steps to attempt to do so:
If I dispose of this object at the end of the 'if' statement block, the app fails to persist its state to disk. This makes sense to me, because my understanding is that this object needs to be present in memory at the time of data persistence in order to facilitate this feature.
If I inject a reference to this object into the constructor of my primary application window, and add it to my disposables, a new bug occurs in which the the application will crash when the user attempts to close it.
Please note that the same bug occurs if I instead call 'desktop.Shutdown()', where 'desktop' is my 'IApplicationLifetime' implementation. It seems that the disposal of the AutoSuspendHelper object in this fashion prevents the closing of the primary application window.
One possible solution that I am not keen on is to subscribe to the 'IApplicationLifetime' 'Exit' event, and dispose of the AutoSuspendHelper instance in an event handler.
This approach does 'work' in that it demonstrably disposes of the AutoSuspendHelper instance, but it has a number of drawbacks in my opinion, including:
Please can you confirm whether it is actually necessary to dispose of this object, and if so, how and when?
Let me know if you would like me to provide additional information.
Kind regards,
Joe
All reactions