Respond to UI Messages
-
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
-
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
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
-
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
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 -
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 TwainThe 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
-
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
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 -
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 TwainNot 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.:)
-
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.:)
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