void imageCompressor_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; while (!worker.CancellationPending) { ImageItem item = null; lock (compressLock) { while (compressItems.Count == 0) { Monitor.Wait(compressLock); } item = compressItems.Dequeue(); } compressStorage.Save(item.Time + ".jpg", item); } }
private void ProcessItem(string id) { long itemTime = 0; bool res = long.TryParse(id.Split('.')[0], out itemTime); if (!res || itemTime <= 0) { return; } long lastProcessTime = ((this.lastTime > 0) ? this.lastTime : (itemTime - frameTime - 1)); long diffTime = itemTime - lastProcessTime; if (!useSourceFPS) { if (diffTime < frameTime) { if (config.Render.DeleteImages) { Remove(id); } return; } } long showTime = diffTime; if (!useSourceFPS) { showTime = frameTime; } ImageItem item = new ImageItem(); item.Name = id; item.Time = itemTime; item.ShowTime = showTime; this.lastTime = itemTime; Load(item); }
void imageLoader_DoWork(object sender, DoWorkEventArgs e) { Stopwatch sw = new Stopwatch(); BackgroundWorker worker = (BackgroundWorker)sender; while (!worker.CancellationPending) { ImageItem item; sw.Reset(); sw.Start(); item = GetLoadItem(); lock (renderLock) { while (renderItems.Count > 60) { Monitor.Wait(renderLock); } } ImageItem ii = imageStorage.Load(item.Name); item.ImageData = ii.ImageData; sw.Stop(); worker.ReportProgress(0, item); } }
public abstract bool Save(string id, ImageItem image);
void imageConverter_ProgressChanged(object sender, ProgressChangedEventArgs e) { ImageItem item = e.UserState as ImageItem; Render(item); }
void imagePuller_ProgressChanged(object sender, ProgressChangedEventArgs e) { ImageItem item = (ImageItem)e.UserState; ProcessItem(item); }