C# WPFでメインウィンドウから別スレッドで通信処理を行っている。
メインウィンドウを閉じてアプリケーション終了後に、別スレッドがメモリに残ってしまうことがある。
そんな場合は、プロジェクトのApp.xamlにShutdownMode="OnMainWindowClose"と指定する。
app.xaml
<Application x:Class="GateClient.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
ShutdownMode="OnMainWindowClose"
Startup="Application_Startup"
Exit="Application_Exit">
</Application>