public Bitmap GetBitmap(IconSize size, string fileName, bool isDirectory, bool forceLoad) { Bitmap retVal = null; using (var imgList = new SystemImageList(size)) retVal = imgList[fileName, isDirectory, forceLoad]; //sysImgListLock.AcquireReaderLock(1000); //try //{ // if (!sysImgList.IsImageListInited || size != sysImgList.CurrentImageListSize) // { // LockCookie lockCookie = sysImgListLock.UpgradeToWriterLock(lockWaitTime); // try // { // SystemImageList imgList = sysImgList[size]; // retVal = imgList[fileName, isDirectory, forceLoad]; // } // finally // { // sysImgListLock.DowngradeFromWriterLock(ref lockCookie); // } // } // else // { // retVal = sysImgList[size][fileName, isDirectory, forceLoad]; // } //} //finally { sysImgListLock.ReleaseReaderLock(); } return(retVal); }
public SystemImageList getImageList(IconSize size) { if (currentImageList != null && currentImageListSize == size) { return(currentImageList); } if (currentImageList != null) { currentImageList.Dispose(); currentImageList = null; } currentImageListSize = size; return(currentImageList = new SystemImageList(currentImageListSize)); }