2019-6-14-WPF-shows-that-some-windows-in-multithreading-will-be-locked-in-the-PenThreadWorker-constr...
title | author | date | CreateTime | categories |
---|---|---|---|---|
WPF shows that some windows in multithreading will be locked in the PenThreadWorker constructor when the application starts
|
lindexi
|
2019-06-14 08:50:36 +0800
|
2019-06-11 19:28:43 +0800
|
WPF
|
Problem description:
WPF will initialize pen thread when the window initializing. But I find the window may be locked in PenThreadWorker constructor.
The UnsafeNativeMethods.CreateResetEvent
will lock the thread.
Actual behavior:
I use multithreading to create some windows by this code and maybe the thread be locked in PenThreadWorker constructor.
The Demo code
public partial class App : Application
{
/// <inheritdoc />
protected override void OnStartup(StartupEventArgs e)
{
var thread = new Thread(() =>
{
var mainWindow = new MainWindow();
mainWindow.Show();
Dispatcher.Run();
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
base.OnStartup(e);
}
}
The step
- Run the code
- Use the VisualStudio to suspend the application
Maybe you can find the application only create aStylus Input
thread and show only a main window and the other main window and the thread be locked in PenThreadWorker constructor and the window can not show
Why I need multithreading to show the windows? I need the splash window to show the welcome page and then I should show the main window in other thread to do the bussiness code and I should close the splash window when the main window showed.
But I found some users could not show the main window and the main window be lock in PenThreadWorker constructor.
I use dnspy to suspend the application and find the code run in PenThreadWorker constructor and theUnsafeNativeMethods.CreateResetEvent
will lock the thread.
PenThreadWorker..ctor()
PenThread..ctor()
PenThreadPool.GetPenThreadForPenContextHelper(PenContext penContext)
PenThreadPool.GetPenThreadForPenContext(PenContext penContext)
WispTabletDeviceCollection.UpdateTabletsImpl()
WispTabletDeviceCollection.UpdateTablets()
WispTabletDeviceCollection..ctor()
WispLogic.get_WispTabletDevices()
WispLogic.RegisterHwndForInput(InputManager inputManager, PresentationSource inputSource)
HwndStylusInputProvider..ctor(HwndSource source)
HwndSource.Initialize(HwndSourceParameters parameters)
HwndSource..ctor(HwndSourceParameters parameters)
PresentationFramework.dll!System.Windows.Window.CreateSourceWindow(bool duringShow)
PresentationFramework.dll!System.Windows.Window.CreateSourceWindowDuringShow()
PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox)
Expected behavior:
The UnsafeNativeMethods.CreateResetEvent
do not lock the thread
Minimal repro:
Create a empty WPF application and then change the app.xaml.cs code
public partial class App : Application
{
/// <inheritdoc />
protected override void OnStartup(StartupEventArgs e)
{
var thread = new Thread(() =>
{
var mainWindow = new MainWindow();
mainWindow.Show();
Dispatcher.Run();
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
base.OnStartup(e);
}
}
Run the code and maybe you can find one of the main window can not show and it stop in UnsafeNativeMethods.CreateResetEvent
and I wait for a hour but it can not run.
2019-6-14-WPF-shows-that-some-windows-in-multithreading-will-be-locked-in-the-PenThreadWorker-constr...的更多相关文章
- 每日一练ACM 2019.04.14
2019.4.14 第1001题:Sum Problem Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Onli ...
- 通过 AppSwitch 禁用 WPF 内置的触摸让 WPF 程序可以处理 Windows 触摸消息
原文:通过 AppSwitch 禁用 WPF 内置的触摸让 WPF 程序可以处理 Windows 触摸消息 WPF 框架自己实现了一套触摸机制,但同一窗口只能支持一套触摸机制,于是这会禁用系统的触摸消 ...
- 在 WPF 程序中应用 Windows 10 真?亚克力效果
原文:在 WPF 程序中应用 Windows 10 真?亚克力效果 从 Windows 10 (1803) 开始,Win32 应用也可以有 API 来实现原生的亚克力效果了.不过相比于 UWP 来说, ...
- WPF关于“在“System.Windows.Markup.StaticResourceHolder”上提供值时引发了异常。”问题解决办法
在WPF中添加样式,在MainWindow.xaml使用自定义按钮FButton时报错,报错信息如下: "System.Windows.Markup.XamlParseException&q ...
- IntelliJ IDEA 最新版 2019.2.4 激活 (持续更新)(含windows和Mac)
IntelliJ IDEA 最新版 2019.2.4 激活 最新版激活包下载地址: 百度网盘 提取码: i28c 转载: Neo Peng Jetbrains系列产品 激活方式 同下述方式相同,只需要 ...
- WPF 利用HwndSource拦截Windows消息
WPF提供了一个HwndSource可以使你更快的实现处理Windows消息. 通过HwndSource.FromHwnd得到的HwndSource可以添加(AddHook)移除(Remove)Hoo ...
- WPF中使用System.Windows.Interactivity实现事件绑定的替代方法
一.问题描述 对于 Button 等控件,在 MVVM 中我们能通过 Command 绑定解决 Click 事件.具体如下所示: <Button Margin="10" He ...
- WPF程序中处理Windows消息
首先通过WindowInteropHelper类,我们可以获取WPF Window的Handle. WindowInteropHelper helper = new WindowInteropHelp ...
- WPF自定义窗口(Windows Server 2012 Style)
先上图 新建CustomControl,名:HeaderedWindow Themes\Generic.aml文件夹下加入 笔刷,转换器 <SolidColorBrush x:Key=" ...
- 2019.4.14 python基础30
前面学习的变量,数据类型(整型,浮点数,布尔),序列(字符串,列表,元祖,字典,集合) ,可以看做是数据的组织方式.数据可以看做是“砖块”! 流程控制语句是代码的组织方式,可以看做是“混凝土” 一个完 ...
随机推荐
- C++ 系列:随机数
C++中没有自带的random函数,要实现随机数的生成就需要使用rand()和srand().不过,由于rand()的内部实现是用线性同余法做的,所以生成的并不是真正的随机数,而是在一定范围内可看为随 ...
- Android开发 navigation的跳转动画实现
前言 此篇博客只简短的介绍navigation如何添加跳转页面的动画属性,如果你还为接触了解过navigation.建议你看我另一篇博客Android开发 navigation入门详解 创建动画xml ...
- jmeter遇到的问题:java.net.ConnectException: Connection refused: connect
1.使用jmeter执行脚本,在察看结果树的的响应数据中看到的错误提示如下: java.net.ConnectException: Connection refused: connect at jav ...
- 校园商铺-4店铺注册功能模块-10店铺注册之js实现
1. 建立js目录和文件 1.1 建立js目录 在webapp下新建文件夹js,再在js目录下新建shop文件夹. 1.2 js文件 js的功能: 1.从后台获取到店铺分类.区域等是信息,将它填充到前 ...
- CommonsMultipartResolver 文件上传
依赖 <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fi ...
- javaScript 习题总结(持续更新)
判定偶数 function collect_all_even(collection) { return collection.filter(item => item%2 == 0); } 两个集 ...
- LUOGU P4253 [SCOI2015]小凸玩密室(树形dp)
传送门 解题思路 玄学树形\(dp\),题目描述极其混乱...看错了两次题,设首先根据每次必须点完子树里的灯才能点别的,那么点灯情况只有两种,第一种是点到某一个祖先,第二种是点到某一个祖先的兄弟.所以 ...
- DELPHI指针的使用
DELPHI指针的使用 大家都认为,C语言之所以强大,以及其自由性,很大部分体现在其灵活的指针运用上.因此,说指针是C语言的灵魂,一点都不为过.同时,这种说法也让很多人产生误解,似乎只有C语言的指针才 ...
- R语言中的线性判别分析_r语言 线性判别分析
R语言中的线性判别分析_r语言 线性判别分析 在R语言中,线性判别分析(Liner Discriminant Analysis,简称LDA),依靠软件包MASS中有线性判别函数lqa()来实现.该函数 ...
- Python collection模块与深浅拷贝
collection模块是对Python的通用内置容器:字典.列表.元组和集合的扩展,它包含一些专业的容器数据类型: Counter(计数器):dict子类,用于计算可哈希性对象的个数. Ordere ...