Application.DoEvents的用法
Application.DoEvents 方法
當執行 Windows 窗體時,它將建立新窗體,然後該窗體等待處理事件。該窗體在每次處理事件時,均將處理與該事件關聯的所有程式碼。所有其他事件在佇列中等待。在程式碼處理事件時,應用程式並不響應。例如,當將另一視窗拖到該視窗前面時,該視窗不重新繪製。
如果在程式碼中呼叫 DoEvents,則應用程式可以處理其他事件。例如,如果向 ListBox 新增資料的窗體,並將 DoEvents 新增到程式碼中,那麼當將另一視窗拖到該窗體上時,該窗體將重新繪製。如果從程式碼中移除 DoEvents,那麼在按鈕的單擊事件處理程式執行結束以前,改窗體不會重新繪製。
通常,在迴圈中使用該方法來處理訊息。
參考:
When you run a Windows Form, it creates the new form, which then waits for events to handle. Each time the form handles an event, it processes all the code associated with that event. All other events wait in the queue. While your code handles the event, your application does not respond. For example, the window does not repaint if another window is dragged on top.
If you call DoEvents in your code, your application can handle the other events. For example, if you have a form that adds data to a and add DoEvents to your code, your form repaints when another window is dragged over it. If you remove DoEvents from your code, your form will not repaint until the click event handler of the button is finished executing. For more information on messaging, see .
Unlike Visual Basic 6.0, the DoEvents method does not call the method.
Typically, you use this method in a loop to process messages.
Caution |
---|
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see . |
Caution
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see Asynchronous Programming Overview.
Caution |
---|
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see . |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26273052/viewspace-1055609/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Qdrant用法;Qdrant在langchain裡的用法LangChain
- SQL AS 的用法SQL
- SUBMIT 的用法MIT
- indexOf()的用法Index
- Promise的用法Promise
- PHPdefine()的用法PHP
- SqlParameter的用法SQL
- Tcpdump 的用法TCP
- Javascript 的 this 用法JavaScript
- top的用法
- iptables的用法
- tie的用法
- SqlServer的with(nolock)的用法SQLServer
- Oracle的Cast的用法OracleAST
- jQuery的:checked的用法jQuery
- PHP Session的用法PHPSession
- meta元素的用法
- React Hooks 的用法ReactHook
- MongoDB的基本用法MongoDB
- React ref的用法React
- webpack的基本用法Web
- rematch的基本用法REM
- Pythonyield的用法Python
- Vue slot的用法Vue
- Mysql LIMIT的用法MySqlMIT
- Promise的基本用法Promise
- js中的this用法JS
- Seajs的用法JS
- *html的CSSHacks用法HTMLCSS
- java Properties的用法Java
- golang range的用法Golang
- 【SqlServer系列】AS的用法SQLServer
- Oracle Hints的用法Oracle
- oracle job的用法Oracle
- OpenCV的SVM用法OpenCV
- Oracle keep的用法Oracle
- SQL 中With as 的用法SQL
- WITH的簡單用法