投稿

5月, 2024の投稿を表示しています

.NETのメッセージボックス

 .NETのFormとかWPFなどのGUIでは、UIイベント処理中は普通は他のイベントは処理されない。ただし、メッセージボックス表示中はTimer.Tick等は動いてしまう。 参考: Timer.Tick イベントでMessageBoxを呼ぶと死ぬ件について(https://lets-csharp.com/death-of-messagebox/) しかし、常にそうとは限らないようだ。  WPFで以下のようなコードを書くと、DefaultDesktopOnlyの場合だけ、メッセージボックス表示中にtimer_Tickが呼ばれていないようだ。 Class MainWindow     Private timer as System .Windows.Threading.DispatcherTimer     Private Sub Window_Loaded ( sender as Object , args as EventArgs )         timer = new System.Windows.Threading.DispatcherTimer         timer. Interval = TimeSpan. FromMilliseconds ( 200 )         AddHandler timer.Tick, AddressOf timer_Tick         timer. Start ()     End Sub     Private Sub timer_Tick ( sender as Object , args as EventArgs )         ClockText. Text = DateTime .Now. ToString ( "HH:mm:ss" )     End Sub     Private Sub Butt...