public TexturePipeline(GridClient client, int maxRequests)
{
running = true;
this.client = client;
maxTextureRequests = maxRequests;
requestQueue = new List<TaskInfo>();
currentRequests = new Dictionary<UUID, int>(maxTextureRequests);
completedDownloads = new Dictionary<UUID, ImageDownload>();
resetEvents = new AutoResetEvent[maxTextureRequests];
threadpoolSlots = new int[maxTextureRequests];
// Pre-configure autoreset events/download slots
for (int i = 0; i < maxTextureRequests; i++)
{
resetEvents[i] = new AutoResetEvent(false);
threadpoolSlots[i] = -1;
}
client.Assets.OnImageReceived += Assets_OnImageReceived;
client.Assets.OnImageReceiveProgress += Assets_OnImageReceiveProgress;
// Fire up the texture download thread
downloadMaster = new Thread(new ThreadStart(DownloadThread));
downloadMaster.Start();
}