Announcement

Collapse
No announcement yet.

What is the proper way to update the UI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is the proper way to update the UI

    When using listviews or any control and I have spawned multiple threads, what is the best way to update the user interface? is it best done through send/post message to the window or directly against the control?

    Thanks in advance
    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

  • #2
    GUI + Worker Thread + Abort Demo
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      According to M$ and .NOT you should never update the GUI from another thread. They claim it causes issues...or they just don't know how to program (I'm leaning to the latter). For some dumb reason in .NOT my couple lines of code turns into an hour of typing extra garbage to allow my thread to update the UI. Thankfully I don't have to use it for everything...and can use an approach like MCM's.
      sigpic
      Mobile Solutions
      Sys Analyst and Development

      Comment


      • #4
        I don't know squat about .NET but

        A) That demo does update the GUI screen from another thread of execution (CONTROL SET TEXT is called from thread function)
        B) I have never, never, ever had a problem updating the text of a window whose WndProc executes in another thread of execution.

        MCM
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          See, that is my concern, MS does recommend only updating the UI from the main thread. FYI: in most cases .net will throw an exception when updating the UI out of the main thread.
          Sr. Software Development Engineer and Sr. Information Security Analyst,
          CEH, Digital Forensic Examiner

          Comment


          • #6
            Yep, I had a 30min argument/discussion with an M$ guy when they were explaining the long drawn out process of updating a simple progressbar from another thread. He said it caused issues and locking up and painting problems, etc. He couldn't show me one example though that was caused by a thread and not just bad programming. The real problem was he only had .NET experience and no real programming, so had no clue how to do anything. He just wanted Visual Studio to hold his hand and tell him everything will be alright. Every app I have that uses threads updates the UI in some way.
            sigpic
            Mobile Solutions
            Sys Analyst and Development

            Comment

            Working...
            X