Application.Current.Shutdown(-1) not closing WPF app

后端 未结 2 1901
粉色の甜心
粉色の甜心 2020-12-19 10:22

I am checking if the windows authenticated user is a valid user for my wpf application or not.

If not, I need to shut down the application; but even after executing

相关标签:
2条回答
  • 2020-12-19 10:50

    I have never had luck shutting something down from the start-up. I would suggest starting a new Thread that, after some brief delay, shuts down the application using similar code that you have in your sample.

    0 讨论(0)
  • 2020-12-19 10:54

    Use Environment.Exit() instead. That will try to shut down gracefully, but if it can't gracefully, will shut down rudely -- forcefully terminating threads.

    0 讨论(0)
提交回复
热议问题