Esempio n. 1
0
        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);
                    }
                }
            });
        }
Esempio n. 2
0
        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
            }
        }
        public void OnImageFileNotifycation(ImageObj obj)
        {
            var temp = ImageLoadedCompletedNotify;

            if (temp != null)
            {
                temp(obj);
            }
        }
        public void LoadImage(ImageObj imageObj)
        {
            if (imageObj == null)
            {
                throw new ArgumentException("Invalidate imageObj!");
            }

            if (string.IsNullOrEmpty(imageObj.BillNumber) || string.IsNullOrEmpty(imageObj.BillNumber.Trim()))
            {
                throw new ArgumentException("Invalidate billNumber:{0}!", imageObj.BillNumber.ToString());
            }

            EnsureImageToLocal(imageObj.BillNumber, imageObj.ImageName);
        }
        internal bool IsValidLocalImage(ImageObj temp)
        {
            if (IsSupportedDownloadedDefaultImage())
            {
                var localImageName = Path.Combine(imageLocalDir, temp.ImageName);

                using (FileStream fs = new FileStream(localImageName, FileMode.Open, FileAccess.Read))
                {
                    if (defaultImageSize.HasValue)
                    {
                        var actualValue = defaultImageSize.Value;
                        var length      = fs.Length;
                        if (actualValue == length)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }