Application.DoEvents()

C#中System.Windows.Forms.Application.DoEvents()什么意思? 阅读详情

Application.DoEvents()

 

简介:
其实doEnvents很简单,就是暂停一下当前模块Code,好让你程序可以响应其它事件、消息……  
响应完其它事之后又回去继续执行刚才的Code  (允许窗体在忙时响应 UI 输入)

 

生动描述:
程序对CPU说,哥们,你去干别的事情吧


好处或意义:
全部显示,处理当前在消息队列中的所有Windows消息.
在大量循环中使用可以有效避免假死机现象

 

注意:
调用该方法可以在某消息引发事件时导致重新输入代码.

 

额外了解:
Window窗体运行机制:
当运行Windows窗体时,它将创建新窗体,然后该窗体等待处理事件
该窗体在每次处理事件时,均将处理与该事件关联的所有代码。
所有其他事件在队列中等待。
在代码处理事件时,应用程序并不响应。
例如,当将另一窗口拖到该窗口前面时,该窗口不重新绘制。

 

实例:

  1.         private void btnNone_Click(object sender, EventArgs e)
  2.         {            
  3.             int x=0;
  4.             while (true)
  5.             {
  6.                 x++;
  7.                 Application.DoEvents();//如果没这句程序就假死了
  8.                // Application.Exit();
  9.             }
  10.         }
3D视觉-结构光测量-线结构光测量 线结构光测量中,由激光器射出的激光光束透过柱面透镜扩束,再经过准直,产生一束片状光。这片光束像刀刃一样横切在待测物体表面,因此线结构光法又被成为光切法。线结构光测量常采用二维面阵CCD作为接受器件,因此只要通过增加垂直于面阵探测器的第三维度方向,就可以实现对三维物体的测量。 阅读详情

相关推荐

MODIS 遥感数据批量下载(使用Cygwin)

MODIS 遥感数据批量下载(使用Cygwin)包含Cygwin的下载教程

weixin_45913084的博客 916

Application.DoEvents

Application.DoEvents()的作用:处理所有的当前在消息队列中的Windows消息 如果将自己的程序和主窗体写在同一个线程,那么当自己的代码出现长时间占用线程时,windows消息(鼠标,键盘等消息)不会被处理,使得程序出现假死状态。所以首先建议不要将自己的程序放在主窗体线程中。如果非的这么做不可,可以调用Applicatioin.DoEvents()来将windows消息优先级

Good good study! 1452

AnolisOS网卡驱动源码编译与安装实战指南

本文提供了一份详尽的AnolisOS网卡驱动源码编译与安装实战指南。针对系统自带通用驱动不兼容导致网络无法使用的问题,文章从环境准备、源码获取、编译安装到新旧驱动替换与持久化配置,一步步解析了如何通过源码编译安装官方驱动,解决硬件兼容性问题,并确保驱动在系统重启后自动生效。

weixin_28358083的博客 304

【Winform】关于Application.DoEvents()的理解

Winform开发时,偶尔会在一个耗时的处理中用到Application.DoEvents()这个方法,可以让UI线程在当前代码上下文中切换去处理其它Windows消息,从而避免界面的假死。 例如,经常会这么用:         public static void Delay(int nMilliSeconds)         {   &nbsp

hb571843232的博客 5409

详解Σ-Δ型ADC拓扑结构的基本原理

现在,总环路滤波器的H(f)具有更大的滚降,Mod 2型的噪声传递函数具有40 dB/十倍频程的上升速率。同样,当正弦波输入为负满量程时,+1和–1之间的转换会减少,输出以–1为主。噪声传递函数是一个高通滤波器函数,提供噪声整形,在DC附近的较低频率,对量化噪声有很强的抑制。H(f)是环路滤波器的函数,定义噪声和信号的传递函数。Σ-Δ型ADC的噪底由热噪声决定,而不受量化噪声的限制。量化噪声为量化器的输入与输出之差。图5. Mod 1 Σ-Δ环路的线性模型(b),包括方程、滤波器、信号和噪声传递函数图。

qq_43416206的博客 1810

5.6华为OD机试真题 新系统 - 匹配命令行前缀关键字 (Java/Py/C/C++/Js/Go)

5.6华为OD机试真题 新系统 - 匹配命令行前缀关键字本文整理华为 OD 机试新系统机考真题库,涵盖高频考点精析与完整题目内容,提供 C 语言、Java、C++、Python、Go、JavaScript 多语言源码实现,搭配详细解题思路讲解,并支持在线 OJ 刷题练习,助力高效备考华为 OD 机试新系统。

算法大师! 2129

C# Application.DoEvents()的作用

Application.DoEvents() 方法在 Windows 应用程序中起着重要作用,它可以处理用户事件、系统事件,并在不同领域中的应用中实现各种功能。通过与操作系统的交互,它支持应用程序的运行和用户交互。

qq_35320456的博客 3377

Allegro如何设置走线自动删除重复走线操作指导

Allegro如何设置走线是自动删除重复走线操作指导在PCB布线的时候,点到点需要重复走一段线的时候,希望原来的线段自动被删除,Allegro设计的时候支持这个操作如下图,重复走中间的线段的时候,希望下方的走线自动删除具体操作如下This section is describe what the function allegro have ,helpfully could let user know more about allegroAllegro Design and Analysis includes

weixin_54787054的博客 4499

winform Application.DoEvents();用法

过度使用或在不恰当的时机调用它可能会导致意外的行为,并且可能使代码变得复杂。在现代的 C# 应用程序中,通常推荐使用异步编程模型或其他事件驱动的方法来处理并发和异步操作,以避免在主线程中使用。通常情况下,当应用程序处于事件处理代码块中时,它会一直占用线程并处理事件,直到事件处理完成后才返回到主消息循环。这可能导致应用程序在事件处理期间无响应,因为它无法处理其他待处理的消息。时,它会让应用程序在事件处理过程中暂时中断,处理其他待处理的消息,然后再返回到事件处理代码继续执行。

nbspzs的专栏 2525

18 中望CAD二次开发-DWG参照(ZRX C++)

本文介绍了CAD参考外部dwg文件的原理和代码实现及如何卸载参考文件的全过程,是中望CAD二次开发中重要的功能。

cilvsuanna的博客 207

SPICE仿真软件:HSPICE_(22).HSPICE仿真案例分析

通过上述案例分析,我们可以看到HSPICE仿真软件在不同电路类型和仿真场景中的应用。无论是简单的直流分析、交流分析还是复杂的暂态分析,HSPICE都能提供详细的仿真结果,帮助我们更好地理解和优化电路设计。希望这些案例能够为读者提供实用的参考和指导,进一步提升使用HSPICE进行电路仿真的能力。输入文件的编写:确保输入文件格式正确,使用注释来解释每一部分的内容。分析类型的选择:根据电路的特点选择合适的分析类型,如.DC.AC和.TRAN。输出结果的设置:使用.print命令来指定需要输出的节点电压和支路电流。

kkchenjj的博客 1309

Application.DoEvents()那些事

是什么 初识Application.DoEvents()是看托管D3D代码。一般winform的Main函数是这样的: [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Appl...

光头涛的博客 1882

YOLOv11涨点改进| TPAMI 2026 |独家创新首发、Conv改进篇| 引入LPM 局部先验特征增强模块,更加聚焦于目标区域并抑制背景干扰,助力目标检测、图像分割、图像恢复、图像增强有效涨点

🔥本文提出了一种改进YOLOv11网络的LPM(局部先验特征增强)模块,通过构建重要性图引导特征提取过程,使模型更聚焦目标区域并抑制背景干扰。LPM模块通过注意力机制强化关键区域信息,优化特征分布,提升小目标和复杂场景下的检测性能。实验表明,该模块在保持轻量结构的同时,显著提高了检测精度和鲁棒性。文章详细介绍了LPM的结构原理、核心代码实现方法,并提供了4种改进配置方案(yolov11n_LPM.yaml等),指导用户如何集成该模块到YOLOv11网络中。这些改进方案通过多阶段特征融合逐步强化细节表达.

Ai缝合怪、助力小伙伴高效发论文 127

WPF 中实现 Winfrom 中 Application.DoEvents() 方法

熟悉 Winfrom 中 Application.DoEvents() 方法的朋友一定用过此方法,此方法可以立即处理当前在消息队列中的所有 Windows 消息。 如在一个按钮单击事件中,需要每一秒改变label的Text属性,如下代码: private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 50; i++) {

程序员奶爸 1647

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

Application.DoEvents()的作用

Application.DoEvents()的作用:处理当前在消息队列中的所有 Windows 消息。 private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 10000; i++) { ...

u014712365的博客 2145

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C# 中 Application.DoEvents() 的作用

Application.DoEvents() 的作用

weixin_44768602的博客 1921

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

关于Application.DoEvents()

记得第一次使用Application.DoEvents()是为了在加载大量数据时能够有一个数据加载的提示,不至于系统出现假死的现象,当时也没有深入的去研究他的原理是怎样的,结果在很多地方都用上了Application.DoEvents(),今天看到了关于这方面的一些文章,知道我以前有些用法是不当的,有些地方需要慎用Application.DoEvents()。 首先我们先看看在循环比较大的程序中

lchyz89的专栏 771

C#中Application.DoEvents()的作用

Python 1.python入门 补: 1.setup.py 2.Cython

Major_S的博客 987

C#经典之Application.DoEvents()的使用

最近做了一个文件上传的模块,因为牵扯到电脑文件的扫描,想做一个实时显示当前扫面文件的功能,就类似于360文件扫描时的效果,本来打算用多线程来实现,但是方法太多没有实现,后来在程序中进行控制,由于文件太多,出现了假死现象,就连自己定义好的Timer计时器都出出现了假死,所以这个问题必须解决,随后在座的过程中,突然发现了Application.DoEvents(),使用了一下,效果很好,解决了自己遇...

weixin_30861797的博客 1740

java application.doevents_关于Application.DoEvents()的小研究

关于Application.DoEvents()的小研究在MSDN中的备注是:当运行 Windows 窗体时,它将创建新窗体,然后该窗体等待处理事件。该窗体在每次处理事件时,均将处理与该事件关联的所有代码。所有其他事件在队列中等待。在代码处理事件时,应用程序并不响应。例如,当将另一窗口拖到该窗口前面时,该窗口不重新绘制。如果在代码中调用 DoEvents,则您的应用程序可以处理其他事件。例如,如果...

weixin_39926943的博客 308

Application.DoEvents()的应用

<br /> <br />当我们在事件里面进行大量的循环操作时,windows将等待循环结束。此时界面是得不到响应的。为了在WinForm界面上实时地显示每次循环得到的结果,可以用.net提供的Application.DoEvents()。<br />PublicClass Form1<br />    PrivateSub wndButtonGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wndBut

Giselite的专栏 1454

Application.DoEvents()作用

Visual Studio里的摘要:处理当前在消息队列中的所有 Windows 消息。 交出CPU控制权,让系统可以处理队列中的所有Windows消息 比如在大运算量循环内,加Application.DoEvents可以防止界面停止响应 因为winform的消息循环是一个线程来处理,那么假如你的某个操作比较耗时,那么消息处理得等你这个耗时操作做完了才能继续,而Application.DoEvents方法就是允许你在耗时操作的内部调用它,而去处理消息队列中的消息。 像鼠标移动鼠标点击都是window..

xianweizuo的博客 1061
上一篇: 接口-^^-显示接口
下一篇: C# 应用程序中更改图标
xochenlin
博客等级 码龄19年 11粉丝 21原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值