zoukankan      html  css  js  c++  java
  • [转载]:Invoke and BeginInvoke





    To begin, from your link:

    • Control.Invoke: Executes on the UI thread, but calling thread waits for completion before continuing.
    • Control.BeginInvoke: Executes on the asynchronous UI thread, and calling thread doesn't wait for completion.

    and from MSDN:

    BeginInvoke executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.

    To sum it up, BeginInvoke is asynchronous. When BeginInvoke is called from the UI thread the request will be executed in parallel with the UI thread. Which means it may not execute until after the currently executing method has returned. So in this case the text box will never appear to update because the for loop will not be interrupted, as the calling thread will not wait for this event to be completed before continuing.

    Alternatively, Invoke is synchronous. The text box will be updated because the calling thread will wait for the call to complete before continuing execution.

    http://stackoverflow.com/questions/1909839/invoke-and-begininvoke
    做个快乐的自己。
  • 相关阅读:
    A
    N
    M
    L
    K
    J
    sass
    通过ps给透明通道的图片添加灰度(适用于需要兼容IE7,效果很好)
    CSS十一问——好奇心+刨根问底=CSSer
    清除浮动的7种方法
  • 原文地址:https://www.cnblogs.com/Jessy/p/2170010.html
Copyright © 2011-2022 走看看