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;
            }
        }