Hello,

I have a GUI with a timer... but when I put too many lines of code inside the timer method, the GUI lags.

private void timer_tick(object sender, EventArgs e) { ... }

How could I resolve this problem? I know there are 3 types of timer... Do I use the correct one?

Any help is appreciated.

What is the code doing? If it is on the main thread and it is doing a lot it can freeze the UI. Consider running the code on another thread.

Thanks for the reply.

The code only changes some labels on the main thread. How can I run the code in another thread?

There are various ways. BackgroundWorker is probably best.

I mark this question as solved, but please could you show me how can I use BackgroundWorker in my case?

After adding the BW, I have backgroundWorker_DoWork() method. Where should I put the code for the labels? There? And that method runs at regular intervals?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.