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