private void ImagePainterWork(object sender, DoWorkEventArgs e) { Snapshot previousSnapshot = null; EyeWeb previousEyeWeb = null; Image previousImage = null; Point previousPoint = new Point(0, 0); while (!Stop) { bool changed = false; //input Snapshot snapshot = ThreadControlCenter.Main.ActiveSnapshot; Image originalImage = ThreadControlCenter.Main.OriginalImage; Point point = ThreadControlCenter.Main.LeftPoint; EyeWeb eyeWeb = ThreadControlCenter.Main.ActiveEyeWeb; //output Bitmap editedOriginal = ThreadControlCenter.Main.EditedOriginal; Bitmap left = ThreadControlCenter.Main.OutputBitmapLeft; Bitmap right = ThreadControlCenter.Main.OutputBitmapRight; Bitmap mono = ThreadControlCenter.Main.OutputBitmapMono; if (eyeWeb == null) { System.Threading.Thread.Sleep(1); continue; } Parallel.For(0, 4, i => { switch (i) { case 0: { if (point != previousPoint || eyeWeb != previousEyeWeb || originalImage != previousImage) { changed = true; if (DrawOriginal) { editedOriginal = eyeWeb.DrawOn(originalImage, point); } else { editedOriginal = eyeWeb.DrawOn(originalImage, point, true); } } } break; case 1: if (snapshot != previousSnapshot) { changed = true; left = eyeWeb.DrawSnapshot(snapshot.Left); } break; case 2: if (snapshot != previousSnapshot) { changed = true; right = eyeWeb.DrawSnapshot(snapshot.Right); } break; case 3: if (snapshot != previousSnapshot) { changed = true; mono = eyeWeb.DrawSnapshot(snapshot.Mono); } break; } }); if (changed) { ThreadControlCenter.Main.OutputBitmapLeft = left; ThreadControlCenter.Main.OutputBitmapMono = mono; ThreadControlCenter.Main.OutputBitmapRight = right; ThreadControlCenter.Main.EditedOriginal = editedOriginal; previousSnapshot = snapshot; previousImage = originalImage; previousEyeWeb = eyeWeb; previousPoint = point; } else { System.Threading.Thread.Sleep(1); } } }