WPF + PostSharp’ed View Model get frozen in a minute

dnogin's Avatar


17 Sep, 2018 02:43 AM

WPF starts ignoring property change notifications after a minute of intensive work. Here is a demo to reproduce (also on GitHub). View model is:

public class Model
    public List<Test> Tests { get; } = new List<Test>();
    public Test Test { get; set; }


public class Test
    public string Name { get; set; }


<Window x:Class="Demo.MainWindow"
        Title="MainWindow" Height="450" Width="800">
            <local:Test Name="a"/>
            <local:Test Name="b"/>
            <local:Test Name="c"/>
            <local:Test Name="d"/>
    <TextBox DockPanel.Dock="Top" Text="{Binding Test.Name, Mode=OneWay}"/>

And the code behind:

public partial class MainWindow : Window
    public MainWindow()

        Timer = new DispatcherTimer();
        Timer.Interval = TimeSpan.FromMilliseconds(250);
        Timer.Tick += Timer_Tick;

    DispatcherTimer Timer { get; }
    Random Random = new Random();
    Model Model => DataContext as Model;

    private void Timer_Tick(object sender, EventArgs e)
        var i = Random.Next(Model.Tests.Count);
        Model.Test = Model.Tests[i];

Run it and wait a minute – window will get frozen.

Here is how I bypassed the problem for now - it looks working:

public class Test : INotifyPropertyChanged
    public string Name { get; set; }

    public event PropertyChangedEventHandler PropertyChanged = delegate { };
    void OnPropertyChanged(string propertyName) => 
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  1. Support Staff 1 Posted by PostSharp Techn... on 20 Sep, 2018 04:08 PM

    PostSharp Technologies's Avatar
  2. PostSharp Technologies closed this discussion on 20 Sep, 2018 04:08 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac