public ConfigurationWindow()
        {
            InitializeComponent();
            this._synchronizationContext = SynchronizationContext.Current;

            // Test threading
            var thread = new ThreadService();

            // Set new screen.
            Screen = new Screen();

            //DispatchTimer = new DispatcherTimer(
            //    TimeSpan.FromMilliseconds(RefreshRate),
            //    DispatcherPriority.Background,
            //    DispatchTimer_TickAsync,
            //    Application.Current.Dispatcher);
            // TODO: Reenabled timer.
            //DispatchTimer.Start();

            // Setup processing network
            ImageProcessingNetwork = new ImageProcessingNetwork(CaptureImage, ChooseFolderButton, CancelButton, HeadBlock);

            while (true)
            {
                Thread.Sleep(1500);
                var(index, value) = Singleton.PopValue();
                if (index > -1)
                {
                    Logging.Log($"[{DateTime.Now.ToLongTimeString()}] Main Thread iterating Singleton, popping #{value} at {index} index");
                }
            }

            // Setup capture processing network
            //CaptureProcessingNetwork = new CaptureProcessingNetwork(CaptureImage, CancelButton, HeadBlock);
        }
        private void ChooseFolderButton_Click(object sender, RoutedEventArgs e)
        {
            // Create a FolderBrowserDialog object to enable the user to
            // select a folder.
            FolderBrowserDialog dlg = new FolderBrowserDialog
            {
                ShowNewFolderButton = false
            };



            // Set the selected path to the common Sample Pictures folder
            // if it exists.
            string initialDirectory = System.IO.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures),
                "Sample Pictures");

            if (Directory.Exists(initialDirectory))
            {
                dlg.SelectedPath = initialDirectory;
            }

            // Show the dialog and process the dataflow network.
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Create a new CancellationTokenSource object to enable
                // cancellation.
                CancellationTokenSource = new CancellationTokenSource();

                // Create the image processing network if needed.
                if (HeadBlock == null)
                {
                    HeadBlock = ImageProcessingNetwork.CreateImageProcessingNetwork(CancellationTokenSource);
                }

                // Post the selected path to the network.
                HeadBlock.Post(dlg.SelectedPath);

                // Enable the Cancel button and disable the Choose Folder button.
                ChooseFolderButton.IsEnabled = false;
                CancelButton.IsEnabled       = true;

                // Show a wait cursor.
                Cursor = Cursors.Wait;
            }
        }