私はtxtファイルと以下のようなCVS形式にいくつかの値を持っています、
サンプル番号 g1 g2
0 5 5
1 6 7
2 10 8
3 6 6
4 11 9
. . . . . .
値の表示に関する多くのソリューションがあります。ただし、ライブ信号として再生しようとしています。したがって、ユーザーが再生ボタンを押すと、0. 秒の値から開始し、秒単位で進行する必要があります。
誰かがそれについて解決策を持っていますか?
これにより、1 秒に 1 行ずつ値がコンソールに出力されます。一部の WinForms または WPF コントロールも同様に更新できます。
timer.Start()
そして、再生ボタンから呼び出します。
var timer = new System.Timers.Timer(1000);
// Your CSV reading might happen in here.
List<string> lines = ReadFromCsv();
int lineNumer = 0;
timer.Elapsed += (sender, e) =>
{
if (lineNumer >= lines.Count)
{
timer.Enabled = false;
}
else
{
string line = lines[lineNumer++];
string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string part in parts)
{
// Print every part with width 10 left-justified.
Console.Write("{0,-10}", part);
}
Console.WriteLine();
}
};
timer.Start();