public MainWindow() { InitializeComponent(); // InitializeComponent()によって、チェックボックスのチェックイベントが発生し // mPreferenceの内容が変わるので、InitializeComponent()の後にロードする。 mPreference = PreferenceStore.Load(); mDataGridPlayListHandler = new DataGridPlayListHandler(mDataGridPlayList); mLabelAlbumName.Content = ""; mBackgroundLoad.WorkerSupportsCancellation = true; mBackgroundPlay.WorkerSupportsCancellation = true; mTextBoxBufferSizeMs.Text = string.Format(CultureInfo.InvariantCulture, "{0}", mPreference.BufferSizeMillisec); switch (mPreference.WasapiDataFeedMode) { case WasapiPcmUtil.WasapiDataFeedModeType.EventDriven: mRadioButtonEvent.IsChecked = true; break; case WasapiPcmUtil.WasapiDataFeedModeType.TimerDriven: mRadioButtonTimer.IsChecked = true; break; } Title = string.Format(CultureInfo.InvariantCulture, "PlayPcmWinAlbum {0} {1}", AssemblyVersion, IntPtr.Size == 8 ? "64bit" : "32bit"); LocalizeTexts(); }
private void Term() { Console.WriteLine("D: MainWindow.Term()"); DeleteKeyListener(); // 設定ファイルを書き出す。 PreferenceStore.Save(mPreference); if (mBwContentListBuilder != null) { // 一度もリスト再作成を呼ばない場合、実体が作られない。 mBwContentListBuilder.CancelAsync(); while (mBwContentListBuilder.IsBusy()) { System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, new System.Threading.ThreadStart(delegate { })); System.Threading.Thread.Sleep(100); } } mBackgroundPlay.CancelAsync(); while (mBackgroundPlay.IsBusy) { System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, new System.Threading.ThreadStart(delegate { })); System.Threading.Thread.Sleep(100); } mBackgroundLoad.CancelAsync(); while (mBackgroundLoad.IsBusy) { System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, new System.Threading.ThreadStart(delegate { })); System.Threading.Thread.Sleep(100); } CancelAll(); mPlaybackController.Stop(); mPlaybackController.Term(); }