非同期で同じ処理を繰り返したいときはSystem.Windows.Forms.Timerを使うと便利です
リンク:msdn
https://msdn.microsoft.com/ja-jp/library/system.windows.forms.timer(v=vs.110).aspx
使い方メモ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
using System; using System.Windows.Forms; public class TimerLoop { public void Run() { Timer timer = new Timer(); timer.Tick += new EventHandler(LoopMethod); timer.Interval = 1000; // 1秒(※msec表記) timer.Enabled = true; } public void LoopMethod(object sender, EventArgs e) { // 一定時間間隔で繰り返し実行したい処理を記述 } } |