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 8380469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:27:59+00:00 2026-06-09T16:27:59+00:00

So I have a WPF application written in .NET 4.0. In the application, there

  • 0

So I have a WPF application written in .NET 4.0. In the application, there is an import button, which does an OpenFileDialog searching for an XML file. After it opens the file, it reads through the XML, and retrieves the data from it and stores it in Properties.Settings.Default. Basically, its a system where people can export and import settings. Works nice.

Now, what I want to do is that after an import, it saves the new settings, then KILLS the application and restarts it. Simple, saves settings, starts new instance of the app, kills the old instance.

Properties.Settings.Default.Save();
System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
System.Diagnostics.Process.GetCurrentProcess().Kill();

However, the problem is that often the start of the new instance of the app is before the settings finish saving. So the new instance starts up retrieving the old settings. I figured I could solve this by adding a simple sleep to the process; but this is very hacky.

System.Threading.Thread.Sleep(1000);

What if the save process takes more than 1000 milliseconds? Then the old issue still occurs. I know I can just increase the sleep timer, but I’m sure there has to be a better way. Is there a way to have it so that the last 2 lines dont activate until after the first line finishes?

  • 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-06-09T16:28:00+00:00Added an answer on June 9, 2026 at 4:28 pm

    Never heard of Save being asynchronous, as last resort you could use a FileSystemWatcher to monitor the affected file and call your code when there are no more changes to it.

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

Sidebar

Related Questions

I have a C# application of which some parts are written using WPF (which
I have written a simple WPF application in which I wanted to test the
I have an application written in wpf, which downloads some webpages, parses html code
I have a WPF Browser application, written in C#. In which have a process
I have an application written in .Net 4.0 with WPF. I'm trying to find
I have a small report/logging application written in C#.NET 4.0 and WPF that I
I have a WPF application written in C#. I have made a button. I
I have an application written in c# [WPF] which involves lot of communication with
I have a wpf application written in framework 4. The application is downloaded via
I have to modify a WPF application written in C# that displays a complex

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.