私のプログラムの中には、tantheta
という値があり、それ以降のイベントの発生時に変更を続けるイベントがあります。関数内で3秒をカウントする
問題は、この値がtantheta
の範囲内にあるかどうかを、特定の範囲の0.6 to 1.5
に3秒間保持するかどうかをチェックする必要があることです。
タイマーでいくつか試してみましたが、うまくいかなかったのです。助言がありますか?
EDIT--
DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
//This event is fired automatically 32 times per second.
private void SomeEvemt(object sender, RoutedEventArgs e)
{
tantheta = ; tantheta gets a new value here through some calculation
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = new TimeSpan(0, 0, 5);
timer.Start();
//if condition to check if tantheta is within range and do something
}
void timer_Tick(object sender, EventArgs e)
{
DispatcherTimer thisTimer = (DispatcherTimer)sender;
textBox1.Text = thisTimer.Interval.ToString();
thisTimer.Stop();
return;
}
私はtantheta値は3秒間1に0.6内にとどまるかどうかを確認する必要があります。私はタイマーは良いアプローチですが、別のスレッドに行くので、これらの計算中にアプリケーションがフリーズするのを防ぐことができます。 :/
何を、具体的には、あなたがしようとしたのですか? –
なぜタイマーが機能しないのですか?あなたのコードを表示することができます –
投稿を編集しました – Cipher