0

I have four tabs at the top in WinForm.

If you click on "Fahrt", the DispatcherTimer is executed, continues to run normally in the background and the labels etc from the function are updated. However, if I click up a second, third ... time, he doesn't want to update the label etc anymore. He goes into the IF, I've already checked that, he just doesn't want to do the content with the labels etc anymore, which I can't quite understand.

DispatcherTimer

if (checkTelemetryDatas?.IsEnabled == true) return;
checkTelemetryDatas = new DispatcherTimer();
checkTelemetryDatas.Tick += new EventHandler(checkTelemetryDatasUpdater);
checkTelemetryDatas.Interval = new TimeSpan(0, 0, 0, 0, 1000);
checkTelemetryDatas.Start();

checkTelemetryDatasUpdater Function

https://pastebin.com/RV7rYtuP

I hope you can understand it as far as my English is not the best.

Glad to ask if something is missing. Thank you.

DerJustin
  • 19
  • 4
  • 1
    Why would you try to use a DispatcherTimer in WinForms? Is it WinForms or WPF? The former? Use a `System.Windows.Forms.Timer` (`Interval` is not a TimeSpan in that Timer). – Jimi Jun 08 '21 at 13:33
  • @Jimi If you click on "Fahrt", the DispatcherTimer is executed and should continue to run in the background, even if you go to another tab and go back to "Fahrt". I don't have a lot of experience with the timer and how it continues in the background. And the DispatcherTimer works so far, only as soon as you go to the tab a second time, it doesn't want to update the labels, for example. – DerJustin Jun 08 '21 at 13:42
  • 1
    I won't click on that... thing (it doesn't *sound* exactly a good idea :). The point is,: why are you using a DispatcherTimer in WinForms? Are you mixing WPF and WinForms stuff? Note that the TabControl doesn't create the handles of child Control of TabPages that are not shown. – Jimi Jun 08 '21 at 13:46
  • It shouldn't be a mixture with Winforms and WPF. It's WinForms the program. If you click on the tab, the new shape is set, which everything works. Only when you click on the specific tab should the updater run, which should also update the labels. If I want to display the results as a console, it works, he receives everything, he just doesn't want to put it in the labels and so on. And I just have no idea how to fix it with my learning knowledge. And that's exactly what I need that help. If I can do it in the same style, only better, gladly :) – DerJustin Jun 08 '21 at 14:16
  • 2
    It is a *mix* of WPF and WinForms: DispatcherTimer comes from `System.Windows.Threading` which is part of the `WindowsBase` assembly, hence WPF stuff. -- If you want help in debugging your app, you need to post **here** a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Jimi Jun 08 '21 at 14:19
  • Hi @Jimi , I took my entire test program, made it smaller and zip it so that you can test it. I turned the DispatcherTimer into a normal timer. Start the program, go to "Fahrt" at the top of the tabs, then two buttons for starting a game should appear in the left area. For example, if you click on them again, they will no longer appear. And this update problem is what I can't handle. https://drive.google.com/file/d/1TdI0vlHYKsaldmyStjzOMxhVkbk6BIqD/view?usp=sharing – DerJustin Jun 09 '21 at 18:10

0 Answers0