public void ShowAllLayerImb(ActionMode mode, bool thisThread = false) { Stopwatch sw = new Stopwatch(); sw.Start(); Image <Bgr, byte> imgLayers = ShowModel.GetLayoutImage(mModel, mode); if (!thisThread) { imBox.Invoke(new Action(() => { var x = imBox.Image; imBox.Image = imgLayers; if (x != null) { x.Dispose(); x = null; } imBox.Refresh(); })); } else { var x = imBox.Image; imBox.Image = imgLayers; if (x != null) { x.Dispose(); x = null; } imBox.Refresh(); } }