Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:19:43+00:00 2026-05-29T20:19:43+00:00

(learning c#) I have a C# WPF application which when a certain form is

  • 0

(learning c#)

I have a C# WPF application which when a certain form is launched does not allow the applications process to close. This occurs in both Debug and the released exe file. The process remains until killed via task manager.

It only occurs when this form is loaded, other forms that are loaded and unloaded allow the application to close normally.

Can anyone point our my error?

XAML:

<Window x:Class="FileDownloadService.FileEditorWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="FileEditorWindow" Height="347" Width="618" Name="FileEditor" Background="#FFF1E7E7" ResizeMode="NoResize" Icon="/FileDownloadService;component/Images/Folder%20Concept%20Icons%2034.ico">
    <Grid>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="142,36,0,0" Name="txtDownloadName" VerticalAlignment="Top" Width="135" />
        <Label Content="Download Name" Height="28" HorizontalAlignment="Left" Margin="12,36,0,0" Name="labRef" VerticalAlignment="Top" Width="105" />
        <Label Content="Download URL" Height="28" HorizontalAlignment="Left" Margin="12,70,0,0" Name="labURL" VerticalAlignment="Top" Width="105" />
        <TextBox Height="23" Margin="142,70,0,0" Name="txtURL" VerticalAlignment="Top" HorizontalAlignment="Left" Width="373" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="142,103,0,0" Name="txtSaveLoc" VerticalAlignment="Top" Width="340" />
        <Label Content="Save Location" Height="28" HorizontalAlignment="Left" Margin="12,101,0,0" Name="labSaveLoc" VerticalAlignment="Top" Width="105" />
        <Button Content="Save" Margin="0,0,12,23" Name="btnSave" Click="btnSave_Click" Height="22" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="71" />
        <Button Content="Close" Margin="0,0,89,23" Name="btnClose" Click="btnClose_Click" Height="22" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="61" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="338,36,0,0" Name="txtRef" VerticalAlignment="Top" Width="46" IsReadOnly="True" />
        <Label Content="ID Ref" Height="28" HorizontalAlignment="Left" Margin="288,36,0,0" Name="labID" VerticalAlignment="Top" Width="65" />
        <Button Content="..." Height="23" Margin="488,103,0,0" Name="btnBrowse" VerticalAlignment="Top" HorizontalAlignment="Left" Width="27" Click="btnBrowse_Click" />
        <CheckBox Content="Enabled" Height="16" HorizontalAlignment="Left" Margin="142,12,0,0" Name="ckenabled" VerticalAlignment="Top" />
        <Label Content="File Name" Height="28" HorizontalAlignment="Left" Margin="12,132,0,0" Name="lab_filename" VerticalAlignment="Top" Width="105" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="142,132,0,0" Name="txtSaveName" VerticalAlignment="Top" Width="223" />
        <TextBlock Height="17" Margin="3,0,0,1" Name="txtLastStatus" Text="" VerticalAlignment="Bottom" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="142,161,0,0" Name="txtFreqUnit" VerticalAlignment="Top" Width="46" />
        <Label Content="Download Frequency" Height="28" HorizontalAlignment="Left" Margin="12,159,0,0" Name="labFreq" VerticalAlignment="Top" Width="124" />
        <ComboBox x:Name="cmbFreqVal" ItemsSource="{Binding}" DataContext="{Binding}" Height="23" HorizontalAlignment="Left" Margin="194,161,0,0" VerticalAlignment="Top" Width="69">

        </ComboBox>
    </Grid>
</Window>

CS:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.IO;
using FileDownloadService.ClassLib;
using MessageBox = System.Windows.Forms.MessageBox;

namespace FileDownloadService
{
    /// <summary>
    /// Interaction logic for FileEditorWindow.xaml
    /// </summary>
    public partial class FileEditorWindow : Window
    {
        public string Mode = "none";

        public class FreqUnit
        {
            public string Name { get; set; }
            public string Value { get; set; }
            public override string ToString() { return this.Name; }
        }


        public FileEditorWindow(string args)
        {

            InitializeComponent();

            //build up freqUnit list
            this.cmbFreqVal.Items.Add(new FreqUnit { Name = "Seconds" });
            this.cmbFreqVal.Items.Add(new FreqUnit { Name = "Minutes" });
            this.cmbFreqVal.Items.Add(new FreqUnit { Name = "Hours" });


            if (args == null)
            {
                //do nothing

                Mode = "add";

                //populate default save location
                XmlInterface getConfig = XmlInterface.DeserializeConfiguration(Globals.ConfigFileName);
                txtSaveLoc.Text = getConfig.defaultSaveLoc;


            }
            else
            {
                Mode = "edit";

                //New instance of the editor class
                Editor oEditor = new Editor();

                //launch method to obtain selected record data
                string[] SelectedRecordData = oEditor.ReadRecord(args);

                //is the item enabled or disabled
                bool enabledResult;
                if (SelectedRecordData[4] == "1")
                {
                    enabledResult = true;
                }
                else
                {
                    enabledResult = false;
                }

                //populate form
                txtRef.Text = SelectedRecordData[0];
                txtDownloadName.Text = SelectedRecordData[1];
                txtURL.Text = SelectedRecordData[2];
                txtSaveLoc.Text = SelectedRecordData[3];
                ckenabled.IsChecked = enabledResult;
                txtSaveName.Text = SelectedRecordData[5];
                txtLastStatus.Text = SelectedRecordData[6];
                txtFreqUnit.Text = SelectedRecordData[7];
                cmbFreqVal.Text = SelectedRecordData[8];



            }


        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            var mainForm = new MainWindow();

            Close();


        }


        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (Mode == "add")
            {
                Editor rEditor = new Editor();


                if (rEditor.WriteRecord(Mode, ckenabled.IsChecked, txtDownloadName.Text, txtRef.Text, txtURL.Text, txtSaveLoc.Text, txtSaveName.Text, txtFreqUnit.Text, cmbFreqVal.SelectedItem.ToString()) == true)
                {
                    MessageBox.Show("Item Added Successfully");
                }



            }
            if (Mode == "edit")
            {

                Editor rEditor = new Editor();



                if (rEditor.WriteRecord(Mode, ckenabled.IsChecked, txtDownloadName.Text, txtRef.Text, txtURL.Text, txtSaveLoc.Text, txtSaveName.Text, txtFreqUnit.Text, cmbFreqVal.SelectedItem.ToString()) == true)
                {
                    MessageBox.Show("Item Saved Successfully");
                }

            }


        }

        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {

            var browseDialog = new FolderBrowserDialog();


            browseDialog.RootFolder = Environment.SpecialFolder.MyComputer;

            if (browseDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txtSaveLoc.Text = browseDialog.SelectedPath;
            }

        }



    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:19:47+00:00Added an answer on May 29, 2026 at 8:19 pm

    Well, as per my original comment, I would suggest removing the creation of a window from the close event. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the process of learning WPF coming from WinForms development. I have a
I am learning WPF and have this simple question. How do I set fill
New to wpf and through a learning curve. I have a userControl with a
I've been learning wpf for about a week now.. and i have a basic
I'm still at the early stages of learning WPF and have decided to try
I have a datagrid in a WPF populated from a csv file. This is
Just learning WPF databinding and have a gap in my understanding. I've seen a
As of last night, I decided to start learning about WPF and have been
Still learning this stuff on WPF, themes, derivations, etc. I understand basics on the
I have a WPF application based on PRISM that utilizes the MVVM pattern. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.