Exemplo n.º 1
0
        private async void NextImage(ThreadPoolTimer timer)
        {
            if (_firstTimer)
            {
                timer.Cancel();
                _timer1 = null;

                _firstTimer = false;
            }

            // get next image
            var image = await _reader.GetImage();

            if (image != null)
            {
                // we have to update UI in UI thread only
                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    () => ShowImage(image)
                    );
            }

            if (_timer1 == null)
            {
                _timer1 = ThreadPoolTimer.CreatePeriodicTimer(NextImage, TimeSpan.FromSeconds(18));
            }

            // cleanup
            BmpCache.Cleanup();
        }
Exemplo n.º 2
0
        private void ShowImage(string imageUri)
        {
            // check cache
            if (!BmpCache.Cache.TryGetValue(imageUri, out BmpCache cacheItem))
            {
                cacheItem = new BmpCache
                {
                    Uri          = imageUri,
                    LastShownUtc = DateTime.UtcNow,
                    Bitmap       = new BitmapImage
                    {
                        UriSource = new Uri(imageUri, UriKind.Absolute)
                    }
                };

                BmpCache.Cache[cacheItem.Uri] = cacheItem;
            }

            // display image
            cacheItem.LastShownUtc = DateTime.UtcNow;
            splashImage.Source     = cacheItem.Bitmap;
        }