[VB, C#]Updating a UI element

Discussion in 'Mixed Languages' started by Muerto, May 7, 2015.

  1. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,873
    2,160
    60
    #1 Muerto, May 7, 2015
    Last edited: Jan 12, 2021
    ...
     
  2. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,068
    4,653
    150
    I found this. http://stackoverflow.com/questions/3886171/why-thread-sleep-is-so-cpu-intensive

    and this https://social.msdn.microsoft.com/F...78/sleep-loop-causes-high-cpu?forum=vbgeneral
    Oh, and I don't know if you saw this http://blogs.msmvps.com/peterritchie/2007/04/26/thread-sleep-is-a-sign-of-a-poorly-designed-program/

    And this http://www.codeproject.com/Questions/175229/Threading-and-CPU-usage

    I don't use VB or C#, but I have done threaded programming with Delphi. It's tricky. Usually, the UI is controlled in the main thread, and the worker thread gives the main thread a slice of time, to update the UI. (i.e. respond to "cancel" button or move a progress bar)

    Hope this helps a little...

    :MJ
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Alphawaves

    Alphawaves Admin
    Staff Member

    Aug 11, 2008
    6,789
    22,534
    210
    Would be easier to give an answer if you gave what it is your updating.. I would maybe use an invoke new delegate or even SynchronizationContext :eek:
     
  4. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,873
    2,160
    60
    #4 Muerto, May 8, 2015
    Last edited: Jan 12, 2021
    (OP)
    ...