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 Inputthread 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.CreateResetEventwill 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
前面学习的变量,数据类型(整型,浮点数,布尔),序列(字符串,列表,元祖,字典,集合) ,可以看做是数据的组织方式.数据可以看做是“砖块”! 流程控制语句是代码的组织方式,可以看做是“混凝土” 一个完 ...
随机推荐
- npm 安装vue 报错Failed at the chromedriver@2.46.0 install script 'node install.js'
原因一般是下载源被封了,我们连接淘宝的下载源下载: npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/d ...
- Android开发 了解ViewModel
前言 ViewModel是google推出的一个数据处理框架,ViewModel类是被设计用来以可感知生命周期的方式存储和管理 UI 相关数据ViewModel中数据会一直存活即使 activity ...
- 一阶段项目 总结 之 两张图片对比 手写 jquery 也可以使用beer slider 插件
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title> ...
- 计算几何——直线交点poj1269
求直线交点还是要推一个公式的.. 见博客https://blog.csdn.net/u013050857/article/details/40923789 还要学一下向量的定点比分法 另外poj精度好 ...
- 安装和设置kubectl命令
Linux [root@cx-- ~]# curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.13.5/bin/ ...
- python封装email模块
一.代码 from email.mime.text import MIMEText from email.header import Header from email.utils import pa ...
- h5判断是否为iphonex
js移动端页面判断是否是iphoneX 转自https://blog.csdn.net/weixin_39924326/article/details/80352929 function isIPho ...
- (转)[视频压制/转换技术] I帧 B帧 P帧 IDR帧 等帧用途详细说明
转:http://www.u2game.net/bbs/thread-46116-1-1.html 在视频压制.转换中,经常会看到:I帧 B帧 P帧 IDR帧 等名词,这里就是通用的解释一下这些帧的用 ...
- 实时检测网络状态及是否可以连接Internet
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...
- Git log和reflog
1.log log命令可以显示所有提交过的版本信息.显示信息如下: Administrator@USER-20171026MG MINGW64 ~/Desktop/lyf (master) $ gi ...