I have a form with a TabControl in a Visual Studio project, with 4 tabs.
When I load the form, I prepare only 3 tabs.
If the user switches to the 4th tab, I have to do some math before display data in the tab.
When switching I experience some graphics artefact, as show below:

(don’t look at the blurried, look at the while stripe in the middle and the cutted graphics on the right)
I tried Suspending Layout before doing the math but probably in the TabControl.SelectedIndexChanged the drawing has already begun.
And no, there is no changING event.
How can I solve this issue? Possibly without using a separate thread.
Since you say that the artifact corrects itself after your calculation completes, this is most likely due to the fact that you are not giving the UI thread a chance to update the screen because you’re spending the CPU doing your calculation. You will likely need to use some sort of threading to resolve the issue.
Windows Forms contains a nice
BackgroundWorkercontrol which can make this kind of task pretty simple. Just drag the control from the Toolbox onto your form designer and then create event handlers for theDoWorkandRunWorkerCompletedevents. Put your calculations in theDoWorkhandler and any updates to the UI that need to happen after the calculation completes in theRunWorkerCompletedhandler (its important to note that you should not access any UI elements from theDoWorkhandler).Here is a brief code sample: