public static ClassBrowserImage AddImage(IImage baseImage) { if (baseImage == null) throw new ArgumentNullException("baseImage"); ClassBrowserImage image; bool imgListPresent; lock (lockObj) { image = new ClassBrowserImage(baseImage, imglistEntries.Count); imglistEntries.Add(image); imgListPresent = (imglist != null); } // We need to do the call outside the lock to prevent deadlocks. // We cannot use an async call because we need to ensure that the image is added to the list // before we return. if (imgListPresent) { Gui.WorkbenchSingleton.SafeThreadCall(AddNewImagesToList); } return image; }