Application.Current.Shutdown() doesn't

前端 未结 3 1772
悲哀的现实
悲哀的现实 2020-12-31 20:18

Title\'s about it. WPF app with some WCF stuff for IPC. I call Application.Current.Shutdown() and the app continues on happily. I thought Shutdown

3条回答
  •  孤独总比滥情好
    2020-12-31 21:00

    In my experience all threads have to either be terminated explicitly or be marked as background threads in order for the application to close.

    Here is an example of kicking off a read thread in the background:

    _readThread = new Thread(new ThreadStart(ReadThread));
    _readThread.Name = "Receiver";
    _readThread.Priority = ThreadPriority.Highest;
    _readThread.IsBackground = true;
    _readThread.Start();
    

    The IsBackground property is the key. Without that being set, the thread won't terminate on when you call Shutdown.

提交回复
热议问题