public void LoadImageAsync(ImageObj ware) { ThreadPool.QueueUserWorkItem(arg => { try { EndLoadImageAsync(ware); } catch (Exception ex) { lock (_obj) { if (ImageLoaedExceptionNotify != null) { ImageLoaedExceptionNotify(ex, ware); } } } finally { if (Interlocked.Decrement(ref imageCount) == 0) { finishedEvent.Set(); imageLoader.RegisterOrUpdateImage(imageObjs); } } }); }
public void LoadImageAsync(ImageObj imageObj) { try { singleThread = new Thread((object obj) => { try { imageLoader.LoadImage(imageObj); } catch (Exception ex) { if (ImageLoaedExceptionNotify != null) { ImageLoaedExceptionNotify(ex, imageObj); } } }); singleThread.Start(); } finally { List <ImageObj> singleImageObj = new List <ImageObj>(); singleImageObj.Add(imageObj); imageLoader.RegisterOrUpdateImage(imageObjs); //Dispose Resources } }