Beispiel #1
0
        private static Task <Exif> GetExifFromImage(string file, Image image)
        {
            Exif exif = new Exif();

            Parallel.ForEach(image.PropertyItems, Constants.ParallelOptions,
                             current =>
            {
                var previousPriority          = Thread.CurrentThread.Priority;
                Thread.CurrentThread.Priority = ThreadPriority.Lowest;

                if (Constants.ExifData.ContainsKey(current.Id))
                {
                    exif.SetValue(Constants.ExifData[current.Id], current.Value);
                }

                //Reset previous priority of the TPL Thread
                Thread.CurrentThread.Priority = previousPriority;
            });

            exif.HasBeenSet = true;

            Item item = CacheManager.Items[file];

            item.Exif = exif;
            CacheManager.Items[file] = item;

            return(Task.FromResult(exif));
        }