Touch stops working after showing a Window in a separate thread while the application is starting
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
.NET core 3.1 WPF application, showing a window in a separate thread when the application is starting, touch events stop firing.
### Configuration
.NET core 3.1. WPF.
Windows 10 Pro.
Any architecture.
.NET framework works fine.
### Regression?
.NET framework works fine.
### Other information
Project is attached.
App.xaml.cs
public partial class App : Application
{
private Window Window;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
CreateAndStartBackgroundThreadWithAction(() => CreateWindow());
Thread.Sleep(5000);
}
private void CreateWindow()
{
this.Window = new Window();
this.Window.Content = "Loading application";
this.Window.Show();
Dispatcher.Run();
}
public void Close()
{
this.Window.Dispatcher.BeginInvoke(new Action(() =>
{
this.Window.Close();
}));
}
private static void CreateAndStartBackgroundThreadWithAction(ThreadStart action)
{
var thread = new Thread(action);
thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true;
thread.Start();
}
}
MainWindow.xaml.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Loaded += MainWindow_Loaded;
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
(Application.Current as App).Close();
}
private void Button_PreviewTouchDown(object sender, TouchEventArgs e)
{
var button = sender as Button;
button.Content = button.Content.ToString() + " Is Down";
}
private void Button_PreviewTouchUp(object sender, TouchEventArgs e)
{
var button = sender as Button;
button.Content = button.Content.ToString() + " Is Up";
}
}
[648cbb04-bf98-42c5-ad02-998d47fa1961_SplashScreenTest.zip](https://github.com/dotnet/core/files/6287623/648cbb04-bf98-42c5-ad02-998d47fa1961_SplashScreenTest.zip)
Contributor guide
Assessment
This issue has not been assessed yet.