Browse Source

add issue for thread exception.

thread-issue-repro
Dan Walmsley 8 years ago
parent
commit
d285e23566
  1. 28
      samples/ControlCatalog/MainWindow.xaml.cs

28
samples/ControlCatalog/MainWindow.xaml.cs

@ -1,18 +1,26 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using ReactiveUI;
using System;
using System.Reactive.Linq;
using System.Threading;
namespace ControlCatalog
{
public class MainWindow : Window
{
private Thread _initialThread;
public MainWindow()
{
this.InitializeComponent();
this.AttachDevTools();
//Renderer.DrawFps = true;
//Renderer.DrawDirtyRects = Renderer.DrawFps = true;
Renderer.DrawFps = true;
Renderer.DrawDirtyRects = Renderer.DrawFps = true;
_initialThread = Thread.CurrentThread;
}
private void InitializeComponent()
@ -23,6 +31,22 @@ namespace ControlCatalog
var theme = new Avalonia.Themes.Default.DefaultTheme();
theme.TryGetResource("Button", out _);
AvaloniaXamlLoader.Load(this);
var timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1),
};
Observable.FromEventPattern(timer, nameof(timer.Tick)).Throttle(TimeSpan.FromMilliseconds(500)).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
{
if (Thread.CurrentThread != _initialThread)
{
throw new SystemException();
}
});
timer.Start();
}
}
}

Loading…
Cancel
Save