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

  • Home
  • SEARCH
  • 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 9113873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:04:01+00:00 2026-06-17T04:04:01+00:00

I have a WPF application with a very complex XAMLs, I need a way

  • 0

I have a WPF application with a very complex XAMLs, I need a way to know the point that my application hang on, when I try to pause the execution, the application seems to not be hanging, the pointer will be on this line:

System.Windows.Application myApp;
.
.
.
.
myApp.Run(); // <== this line

This is happening when I change the layout of the task bar or when windows explorer crashed (the task bar is hidden), if I do those changes in a heavy repetition, the application will never recover, but when a small change done, the application will recover after minutes, I need to know the cause of this issue, I doubt in the complex XAMLs of my application, but I need a way to know the page or the component, or the whatever the source of this hang.

* EDIT *

I need a tool or a way to know what is the XAML that consuming the dispatcher time!

* EDIT *

I have got the exact reason of the hang, it is because of creating an instance of ReportViewer in another thread, When I removed the creation of the instance, It worked perfectly, the strange thing, that this mistake is existed in my application long time ago, but the hang has raised recently, I mean: my application will hang when you insert one of these codes in any location of my application:

        new Action(() =>
        {
            ReportViewer rv = new ReportViewer();
        }).BeginInvoke(null, null);

OR

        new Action(() =>
        {
            ReportViewer rv = new ReportViewer();
            rv.Dispose();
        }).BeginInvoke(null, null);

OR

        new Action(() =>
        {
            ReportViewer rv = new ReportViewer();
            rv.LocalReport.ReleaseSandboxAppDomain();
            rv.Dispose();
        }).BeginInvoke(null, null);

My questions:

1- What is the relation between changing the layout of windows (Resizing the task bar or moving it) and the report viewer which is not added to any visual tree, why this cause my application to hang??

2- How I can determine the location of the hang?

3- Some times the application will recover in few minutes (3-5), but some times the hang still for hours and the application will not recover, Why?

4- How I can I determine the component or configuration that caused my application to hang in this circumstances?

By the way, this is a very useful for the others if solved, We have spent very huge time to detect it, but didn’t got the exact reason combined with the ReportViewer that causing the hang!

  • 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-17T04:04:02+00:00Added an answer on June 17, 2026 at 4:04 am

    I will try to answer your questions as completely as I can:

    The ReportViewer control is a Windows Forms control and Windows Forms has an issue that could cause, in the appropriate circumstances, the UI thread to lock and thus the application to hang.

    When a WM_SETTINGCHANGED message is posted by Windows, the event System.Win32.SystemEvents.UserPreferenceChanged gets fired. Some of Windows Forms controls including ReportViewer listen to this event to update themselves when a system setting changes.

    The UserPreferenceChanged event and in contrast to other regular events will call each handler using the SynchronzationContext of the subscribing thread. So if the ReportViewer was created on a thread other than the main UI thread (Dispatcher thread in WPF) the event firing code will try to do an invoke and wait the invoke to be finished which will never happen on that other thread thus freezing the UI.

    To determine the location of the hang you can easily disable the option Enable Just my code in Visual Studio -> Tools -> Options -> Debugging and when the hang occurs just attach the VS debugger to your hung application this will show you that the application is hung inside UserPreferenceChanged event handling on a WaitOne call.

    You can read more about this hang in these articles:

    http://www.ikriv.com/dev/dotnet/MysteriousHang.html

    Windows Forms Form hanging after calling show from another thread

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

Sidebar

Related Questions

I have a wpf application that is leaking memory...is there a way to detect
I have a WPF application that I need to have users access directories in.
I have a WPF application that I need to move to a tray. It
I have a View Model class in a WPF application that has some very
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
I have a WPF application, where as part of the startup, I need to
I have a wpf application using Caliburn.Micro. I need to bind a ListBox to
I have a WPF application that includes buttons with PNG images. The actual images
I have a very simple WPF application in which I am using data binding
I have encountered something very strange, simple WPF application <Window x:Class=ListBoxSelection.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow

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.