I have an MFC dialog based application that shows the spectrum analyser of a sound file. The spectrum analyser is made of a CStatic derived class and is drawn on to using the GDI. I started using a timer to update my spectrum analyser drawing every 1 millisecond.

Everything was working properly, but I noticed that any 'for loops' that I run in my main application interupted my spectrum analyser drawing. So instead of using a timer to keep updating the drawing of my spectrum analyser I did it in a user interface thread.

So from my UI thread I call like this to update the drawing in my CStatic derived class:
Code:
do
{
//m_SpectrumDisplay is my CSpectrumDisplay(Derived from
//CStatic) variable on my main dialog.
  m_pMainDlg->m_SpectrumDisplay.DrawSpectrum(m_pMainDlg->spec_scaled_fft);
	
}while(!bTerminated);
This made the interuptions not as bad, but the drawing still gets interupted a little bit when running for loops in the main dialog. I thought that if I was calling the drawing function in my CStatic derived class from a UI thread that it would not be bothered by the main application. Is this not the case?

Do I have to somehow make my whole CStatic class in a separate thread?

Any insight would be greatly appreciated!
Thanks,
Greg