I have OnPaint() function that does some rendering custom controls. But unfortunately it lags as i add more and more controls. Is there anyway i can make the OnPaint() as a background worker? For eg i have the below code. CustomRenderer.Render() is what i want in a background worker.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (e.Graphics == null)
return;
CustomRenderer.PerformLayout(e.Graphics, customControls);
CustomRenderer.Render(e.Graphics, customControls); //I want this Render in a background thread.
}