craftworkgames / MonoGame.WpfCore

MonoGame embedded inside a WPF app.
MIT License
71 stars 13 forks source link

Fail to Unload resources on Window CLosing. #14

Open BohdanLytvynov opened 3 weeks ago

BohdanLytvynov commented 3 weeks ago

Hello! I have discovered some bug. The problem is that the Unload event doesn't fires when we are closing the main window. So it leads to the problems with Unloading all the game resources. I have found the solution. We can use Dispatcher,ShutdownStarted event instead of Unload event of the Control. I have tested it, it worked properly. Also I have discovered that this problem is a common thing. Here is the ref to Stackoverflow: link

So I suggest to change Unloaded += OnUnloaded; on the 54 line in the MonoGameContent Control to: Dispatcher.ShutdownStarted += OnUnloaded; It works for me.