Beispiel #1
0
        public ImageSource GetImageSourceAsync(string filePath, ImageSource _default, Action <ImageSource> onLoaded)
        {
            if (File.Exists(filePath) is false)
            {
                return(_default);
            }

            void DecodeAction()
            {
                var thumnbnailServis = new ThumbnailService(filePath);

                if (thumnbnailServis.ExistsThumnail is false)
                {
                    CreateThumbnail(filePath);
                }
                Application.Current.Dispatcher.InvokeAsync(() =>
                {
                    onLoaded(GetImageSource(filePath));
                }, DispatcherPriority.ContextIdle);
            }

            if (UsingSingleThread)
            {
                DecodeAction();
            }
            else if (_staWorkerManager != null)
            {
                _staWorkerManager.AddJob(DecodeAction);
            }
            else
            {
                TaskEx.RunOnSta(DecodeAction);
            }
            return(_default);
        }