コード例 #1
0
        public MainPage()
        {
            this.InitializeComponent();

            // create Flickr feed reader for unicorn images
            var reader = new FlickrReader("unicorn");

            TimeSpan period = TimeSpan.FromSeconds(5);
            // display neew images every five seconds
            ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(
                async (source) =>
                {
                    // 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,
                        () =>
                        {
                            // create and load bitmap
                            BitmapImage bitmap = new BitmapImage();
                            bitmap.UriSource = new Uri(image, UriKind.Absolute);
                            // display image
                            splashImage.Source = bitmap;
                        }
                        );
                    }
                }, period);
        }
コード例 #2
0
        public MainPage()
        {
            this.InitializeComponent();

            // create Flickr feed reader for unicorn images
            var reader = new FlickrReader("unicorn");

            TimeSpan period = TimeSpan.FromSeconds(5);
            // display neew images every five seconds
            ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(
                async(source) =>
            {
                // 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,
                                                                                  () =>
                    {
                        // create and load bitmap
                        BitmapImage bitmap = new BitmapImage();
                        bitmap.UriSource   = new Uri(image, UriKind.Absolute);
                        // display image
                        splashImage.Source = bitmap;
                    }
                                                                                  );
                }
            }, period);
        }