Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Respond to UI Messages

Respond to UI Messages

Scheduled Pinned Locked Moved C#
csharpdesigntoolstutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roger CS
    wrote on last edited by
    #1

    I'm writing my first C# Windows Application using Win Forms. The program, a simple utility, is very processing intensive. Once the processing begins it continues for several minutes. I need the program to process UI messages while it is processing data, obviously. I'm not sure how to do this using the runtime. Would some kind person please point me in the right direction? Roger

    N N 2 Replies Last reply
    0
    • R Roger CS

      I'm writing my first C# Windows Application using Win Forms. The program, a simple utility, is very processing intensive. Once the processing begins it continues for several minutes. I need the program to process UI messages while it is processing data, obviously. I'm not sure how to do this using the runtime. Would some kind person please point me in the right direction? Roger

      N Offline
      N Offline
      neroknights
      wrote on last edited by
      #2

      Well this involves some long explanation. It involves some windows understanding before you begin. What's important is that once the process is finished , it must call back on the windows message loop's main thread. I have the perfect article for you. Tale the time to read it. It's worth it. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms06112002.asp

      1 Reply Last reply
      0
      • R Roger CS

        I'm writing my first C# Windows Application using Win Forms. The program, a simple utility, is very processing intensive. Once the processing begins it continues for several minutes. I need the program to process UI messages while it is processing data, obviously. I'm not sure how to do this using the runtime. Would some kind person please point me in the right direction? Roger

        N Offline
        N Offline
        Nick Seng
        wrote on last edited by
        #3

        My first thought would be to use the System.Threading class. Simply set you processing function as a thread and let it run simultaneously as your main thread. Notorious SMC


        The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
        Get your facts first, and then you can distort them as much as you please Mark Twain

        N 1 Reply Last reply
        0
        • N Nick Seng

          My first thought would be to use the System.Threading class. Simply set you processing function as a thread and let it run simultaneously as your main thread. Notorious SMC


          The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
          Get your facts first, and then you can distort them as much as you please Mark Twain

          N Offline
          N Offline
          neroknights
          wrote on last edited by
          #4

          The problem here is what happens if you want to be notified, when your thread is complete. That may be the case for many UI apps. The article I have mentioned explains all this. Cheers

          N 1 Reply Last reply
          0
          • N neroknights

            The problem here is what happens if you want to be notified, when your thread is complete. That may be the case for many UI apps. The article I have mentioned explains all this. Cheers

            N Offline
            N Offline
            Nick Seng
            wrote on last edited by
            #5

            Well, just add a MessageBox function add the end of the method that contains your process Notorious SMC


            The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
            Get your facts first, and then you can distort them as much as you please Mark Twain

            N 1 Reply Last reply
            0
            • N Nick Seng

              Well, just add a MessageBox function add the end of the method that contains your process Notorious SMC


              The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
              Get your facts first, and then you can distort them as much as you please Mark Twain

              N Offline
              N Offline
              neroknights
              wrote on last edited by
              #6

              Not exactly. Again, in most cases you want to do more than add a message box. Say for instance that when the process is finished, you want to write something to a textbox on that form. You MUST NOT update the textbox in the new thread. That is a no no in Windows. You must only update controls on the windows main thread (the win proc). The article I've already mentioned explains all this. Take the time to read it, it's informative and it helped me alot as well.:)

              N 1 Reply Last reply
              0
              • N neroknights

                Not exactly. Again, in most cases you want to do more than add a message box. Say for instance that when the process is finished, you want to write something to a textbox on that form. You MUST NOT update the textbox in the new thread. That is a no no in Windows. You must only update controls on the windows main thread (the win proc). The article I've already mentioned explains all this. Take the time to read it, it's informative and it helped me alot as well.:)

                N Offline
                N Offline
                Nick Seng
                wrote on last edited by
                #7

                Cool. Will look it up.:rose: Notorious SMC


                The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
                Get your facts first, and then you can distort them as much as you please Mark Twain

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups