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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:39:40+00:00 2026-05-13T11:39:40+00:00

I a WPF application I have the following event-handler of a button-click in a

  • 0

I a WPF application I have the following event-handler of a button-click in a code-behind file of a window:

   private void AddNewRecBtn_Click(object sender, RoutedEventArgs e)
    {
            DimRec.Visibility = System.Windows.Visibility.Visible;
            PrBarLayer.Visibility = System.Windows.Visibility.Visible;
            try
            {
                WriteAndClose();
            }
            catch (Exception)
            {
                throw;
            }
    }

These lines of code:

        DimRec.Visibility = System.Windows.Visibility.Visible;
        PrBarLayer.Visibility = System.Windows.Visibility.Visible;    

just make visible a rectangle DimRec with Opacity="0.5" Fill="Gray" for dimming the window during showing ProgressBar and a StackPanel PrBarLayer with a ProgressBar itself.
WriteAndClose(); method performs lots of stuff, including LINQ to SQL query and heavy visualization on the screen, which takes several seconds (while it’s going on, there is nothig happening on the screen, everything seems freezed).

During this period of several seconds I’d like to show user a dimmed window control and a progress bar animated, but the problem is that these layers, which code make visible, in fact don’t appear. If I remove WriteAndClose(); method from this handler, everything is OK – ProgressBar gets visible.

It seems that WPF doesn’t render visually controls at once and then resources are taken to the next method WriteAndClose, everything freezes and then screen get rendered when all is done already and Visibility of layer of progress bar is made Collapsed.

What could be the solution? How I could make ProgressBar show first and only then do remaining heavy stuff?

  • 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-13T11:39:40+00:00Added an answer on May 13, 2026 at 11:39 am

    You will have to move the executing of WriteAndClose to a different thread.

    However, then you will only be able to manipulate the UI using [Control.]Dispatcher.BeginInvoke.

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

Sidebar

Related Questions

I have a .Net client WPF application using System.DirectoryServices and LDAP for authentication. On
I have a following requirement for a very complex UI. (Complex here means there
I've added WindowsMediaPlayer ActiveX to my WPF/MVVM application. Now I need the control to
Greetings I started developing with WPF yesterday and have ran into some issues. I
Basic layout (VB.NET & WPF/XBAP) : I have a MainPage - mainpage.xaml Inside the
If one were to compile and run the following code, one would find that
I have a TabControl and each Tab can contain the same UI but with
I have an issue that on one computer applications developed using the Windows Presentation
sorry for my English. I previously posted this question as: Multiple ViewModels request same
I need to import a RTF document into a FlowDocument for further parsing.. But

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.