C♯(VB)/WPFでインターバルループ(DispatcherTimer()がなんか遅い問題

大体メッセージボックスの表示は4800msくらいになります。
(正常だと3333msくらいになるはず…)

大体メッセージボックスの表示は4800msくらいになります。
(正常だと3333msくらいになるはず…)

  • タグ:
  • タグはありません
<Window x:Class="IntervalTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:IntervalTest"
mc:Ignorable="d">
<x:Code><![CDATA[
public MainWindow(){
InitializeComponent();
var i=0;
var t=new System.Diagnostics.Stopwatch();
t.Start();
//
var timer=new System.Windows.Threading.DispatcherTimer();
timer.Interval=System.TimeSpan.FromMilliseconds(33);
timer.Tick+=(sender,e)=>{
if(i==100) System.Windows.MessageBox.Show($"{t.ElapsedMilliseconds}");
i++;
};
timer.Start();
}
]]></x:Code>
</Window>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX