我已经开始使用 Blazor/Electron 进行实验应用。
我已经 fork 了该项目: https://github.com/SteveSandersonMS/BlazorElectronExperiment.Sample
当应用程序关闭时,需要保存应用程序的状态。 为此,我认为它需要处理关闭事件并在最终关闭之前保存应用程序的状态。
如何处理关闭事件? 您还有其他解决方案吗?
最佳答案
Blazor live cycle没有任何方法可供调用 OnExit
。
一个想法可能是 implement IDisposable on your component并调用 saveState
来自处置
。
If a component implements IDisposable, the Dispose method is called when the component is removed from the UI.
@using System
@implements IDisposable
...
@functions {
public void Dispose()
{
//anti-pattern work around
//liveCycle OnUnload don't exists
save_your_state();
}
}
免责声明:这种方法是一种反模式,它只是一种解决方法,直到更优雅的解决方案准备就绪为止。
关于c# - Blazor/Electron : Handling close event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53481346/