Revert "Delete handling Loaded and Closing event"

This reverts commit 1d5f71d5cd056574682915201c0940ffd955a98e.
Use Dispatcher.InvokeAsync method