optimized background threading performance for loading resources

This commit is contained in:
codeimp 2009-01-24 19:05:58 +00:00
parent 5c8ef7bef1
commit 1d77112622

View file

@ -68,6 +68,7 @@ namespace CodeImp.DoomBuilder.Data
private Queue<ImageData> imageque; private Queue<ImageData> imageque;
private Thread backgroundloader; private Thread backgroundloader;
private volatile bool updatedusedtextures; private volatile bool updatedusedtextures;
private bool notifiedbusy;
// Image previews // Image previews
private PreviewManager previews; private PreviewManager previews;
@ -467,6 +468,7 @@ namespace CodeImp.DoomBuilder.Data
} }
// Done // Done
notifiedbusy = false;
backgroundloader = null; backgroundloader = null;
General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0); General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0);
} }
@ -511,7 +513,11 @@ namespace CodeImp.DoomBuilder.Data
if(image != null) if(image != null)
{ {
// Wait a bit and update icon // Wait a bit and update icon
if(!notifiedbusy)
{
notifiedbusy = true;
General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0); General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0);
}
Thread.Sleep(0); Thread.Sleep(0);
} }
else else
@ -521,11 +527,21 @@ namespace CodeImp.DoomBuilder.Data
if(previews.BackgroundLoad()) if(previews.BackgroundLoad())
{ {
// Wait a bit and update icon // Wait a bit and update icon
if(!notifiedbusy)
{
notifiedbusy = true;
General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0); General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0);
}
Thread.Sleep(0); Thread.Sleep(0);
} }
else else
{ {
if(notifiedbusy)
{
notifiedbusy = false;
General.SendMessage(General.MainWindow.Handle, (int)MainForm.ThreadMessages.UpdateStatusIcon, 0, 0);
}
// Wait longer to release CPU resources // Wait longer to release CPU resources
Thread.Sleep(50); Thread.Sleep(50);
} }