salut,
voila, je dev une appli multithread avec wxWidgets, j'ai 2 threads qui roulent séparément, un avec un sleep de 100ms et un autre 20ms, pourquoi diable ces threads consomment a eux seul 20% de cpu et pourquoi le rundll32.exe ds le gestionnaire des taches prends pareil en cpu, a peu prés 20% ????
voila comment je code mes threads, j'en met qu'un mais le 2e est du meme type :
CRenderThread::CRenderThread(MyFrame *m_frame, MyCanvas *m_canvas) : wxThread()
{
m_pFrame = m_frame;
m_pCanvas = m_canvas;
}
void
*CRenderThread::Entry()
{
if( TestDestroy() != 0 )
return NULL;
wxWindowDC dc( m_pCanvas );
RenderSpectrum(dc);
return NULL;
}
void
CRenderThread::OnExit()
{
wxCriticalSectionLocker locker( wxGetApp().m_critsect );
wxArrayThread& threads = wxGetApp().m_threads;
threads.Remove(
this);
if( threads.IsEmpty() )
{
if( wxGetApp().m_waitingUntilAllDone )
{
wxGetApp().m_waitingUntilAllDone =
false;
wxGetApp().m_semAllDone.Post();
}
}
if( !m_pFrame->IsQuit && m_pFrame->channel )
m_pCanvas->StartRenderThread();
}
void
CRenderThread::RenderSpectrum(wxDC &dc)
{
Sleep( 20 )
// instructions........
}
voila, du coup mon apli prends 60% cpu en comptant rundll32.exe, ce qui est beaucoup trop a mon gout, car de plus je dessine avec RenderSpectrum, ce qui n'ameliore pas la donne.......
Si vous avez des idées ou si quelque chose cloche dans ce code........
PS:mon pc est une merde, DELL dimension celeron 2.4ghz avec 256 de ram, mais est-ce bien normal?
@+;
satellite34
http://www.rootscommunity.com/