Exemplo n.º 1
0
        private void StartSlideshow()
        {
            _slideshowControl              = new SlideshowControl(Settings.Default);
            _slideshowControl.ImageChosen += (o, ie) =>
            {
                _pictureBox.Image = ie.Image;
                _fileName         = Path.GetFileNameWithoutExtension(ie.FileName);
            };
            _slideshowControl.UnhandledExceptionThrown += SlideshowControlCrashed;

            CancellationTokenSource = new CancellationTokenSource();
            Task = Task.Factory.StartNew(() => _slideshowControl.Start(CancellationTokenSource.Token), CancellationTokenSource.Token);
        }
Exemplo n.º 2
0
        private void PictureForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Task != null && Task.Status == TaskStatus.Running)
            {
                CancellationTokenSource.Cancel();

                Task.Wait(TimeSpan.FromSeconds(1));
            }

            Task = null;
            CancellationTokenSource = null;
            _slideshowControl       = null;

            Cursor.Show();
        }