doevents

Does DoEvents effect only the current thread?

爱⌒轻易说出口 提交于 2019-12-10 17:25:19
问题 I have a simple 'Working' form that runs on its own thread to keep the user informed that the application hasn't died during long running operations. In order to get the working form to update I had to insert a DoEvents() call. I'm curious, will this only pump messages for the current thread I'm in, or will it do it for the whole application? I would prefer that the main window stay unresponsive till the operation finishes, so I'm curious as to the behavior. Below is the code for the working

Is DoEvents() also evil in FormClosing?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 10:35:20
问题 On a different question I suggested to use private void Form1_FormClosing(object sender, FormClosingEventArgs e) { while (processingLock) Application.DoEvents(); } in the FormClosing event (with processingLock becoming false immediately after a lengthy calculation was done). It should serve the purpose to have the application close down in an orderly manner and the original poster didn't use threads. On my suggested answer somebody commented that DoEvents is never good, providing this link:

DoEvents() hanging

一个人想着一个人 提交于 2019-12-10 00:32:44
问题 How do I delete this question? I originally thought that the issue was related to DoEvents, but as it turns out, it is not. I have reposted the question here: http://goo.gl/VpAEK with a more appropriate description of the problem. Thanks - I appreciate any guidance on how to handle this... First, I know this question, as a general concept has been asked before - I have (hopefully) a specific variation to ask about. I will also start be saying that I understand the specific reasons not to use

Is DoEvents() also evil in FormClosing?

佐手、 提交于 2019-12-06 04:35:46
On a different question I suggested to use private void Form1_FormClosing(object sender, FormClosingEventArgs e) { while (processingLock) Application.DoEvents(); } in the FormClosing event (with processingLock becoming false immediately after a lengthy calculation was done). It should serve the purpose to have the application close down in an orderly manner and the original poster didn't use threads. On my suggested answer somebody commented that DoEvents is never good, providing this link: Use of Application.DoEvents() I read and (I think) understood the issue. In my opinion (which is still

Is Application.DoEvents() just for WinForms?

大憨熊 提交于 2019-12-05 22:20:28
问题 Is Application.DoEvents() just for forms? I thought that this command was used to ensure that all of the commands before are processed but now after reading the documentation, I'm not sure anymore. 回答1: Yes, it's really aimed at Windows Forms. However, in my view it should be avoided where possible. It's usually used as a hack by developers who don't want to be bothered with putting long-running operations on a different thread... but that means they're introducing re-entrancy issues which

DoEvents, Waiting, and Editing

别等时光非礼了梦想. 提交于 2019-12-04 09:18:49
I have a set of code that contains: Application.Wait (Now + TimeValue("4:00:00")) This is essentially pausing the macro for a four hour window from 3 AM (when it finishs running the code) till 7 AM (when it should resume). The code is on an endless loop essentially. I want the user to be able to have control during that time to edit certain cells. I have tried DoEvents but have not found the way to keep the macro running, yet provide control to the user during that time when the macro is doing nothing but waiting. Any insight would be appreciated. Thanks! EDIT: One more followup question. I

Is Application.DoEvents() just for WinForms?

旧城冷巷雨未停 提交于 2019-12-04 04:42:18
Is Application.DoEvents() just for forms? I thought that this command was used to ensure that all of the commands before are processed but now after reading the documentation , I'm not sure anymore. Yes, it's really aimed at Windows Forms. However, in my view it should be avoided where possible. It's usually used as a hack by developers who don't want to be bothered with putting long-running operations on a different thread... but that means they're introducing re-entrancy issues which can be very hard to track down, as well as still blocking the UI thread for some of the time (and if that

Alternative to Application.DoEvents()

放肆的年华 提交于 2019-11-30 10:23:32
I am developing a messaging system based on webBrowser controls so that I can format the text however I please. When the user is offline and is sent messages, the messages are stored and an event is sent for every message when they log back in. When I set the default html and such for the website, I normally use: while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete) Application.DoEvents(); This works when the program is running normally. When the user is receiving message sent when they are offline, this triggers the next message event and so on, with each message until the last

Avoid Application.DoEvents() in C#

ⅰ亾dé卋堺 提交于 2019-11-29 17:53:43
A lot of good programmers (including a lot of good members of Stackoverflow) are against using Application.DoEvents() whatever the circumstances are. Actually it is even supported with plenty of articles in the net, like this one , this famous debate on SO , ... Though, I'm stuck in a case, where (I) think DoEvents() is the unique exit (lack of experience). That's enough as introduction, let's see some coding. I have a 'serialPort' component to connect with a controller through serial communication, send command and wait for its response, that's all. string response = ""; bool respFlag;

Alternative to Application.DoEvents()

醉酒当歌 提交于 2019-11-29 15:08:07
问题 I am developing a messaging system based on webBrowser controls so that I can format the text however I please. When the user is offline and is sent messages, the messages are stored and an event is sent for every message when they log back in. When I set the default html and such for the website, I normally use: while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete) Application.DoEvents(); This works when the program is running normally. When the user is receiving message sent