コンソール アプリケーションを実行しています。フォームにテキストボックスがあります。別のクラスで過去 5 分間に読み取られたメッセージの数を計算し、その値をテキスト ボックスに表示する必要があります。コードを実行すると、textbox.text の値が正しく表示されます。しかし、UI では、値がテキスト ボックスに表示されていることがわかりません。ただし、実行時にテキストボックスを手動で編集できます。
これが私のコードです:
コードビハインドで
for (int i = 1; i <= numberOfMsgs; i++)
{
    if (addDateTime.AddMinutes(2).Minute==DateTime.Now.Minute)
    {
        //FilesProcessedInFiveMinutes();
        //Thread thread1 = new Thread(new ThreadStart(FiveMinutesMessage));
        //thread1.Start();
        WebSphereUI webSphereUi = new WebSphereUI();
        webSphereUi.count(fiveMinutesCount);
        addDateTime = DateTime.Now;
    }
    fiveMinutesCount = fiveMinutesCount + 1;
}
form.cs 内
public void count(int countValue)
{
    Thread.Sleep(2000);
    txtLastFiveMins.Focus();
    txtLastFiveMins.Text = countValue.ToString();
    txtLastFiveMins.Refresh();
    txtLastFiveMins.Show();
    backgroundWorker1.RunWorkerAsync(2000);
}