-
March 1st, 2014, 10:49 AM
#1
Dialog Box Busy
Hi,
My dialog application uploads a file to a microprocessor system through an RS-232 port.
Clicking a button starts uploading.
While running the application doesn't accept any button clicks.
A progress bar is following the upload procedure.
The problem is that very often the progress bar freezes and a sand clock shows up. The process always goes to the end and eventually the progress bar gets completed but but meanwhile everything stays frozen.
The same happens if the user tries to move the dialog while running or change the focus out of the dialog.
Does anybody know how to fix similar issues?
Thanks,
Ivan
-
March 1st, 2014, 11:03 AM
#2
Re: Dialog Box Busy
Just move the code working with the serial port into a worker thread. Use PostMessage to inform the main GUI thread about the progress bar position.
Have a look at the Using Worker Threads
Victor Nijegorodov
-
March 1st, 2014, 04:44 PM
#3
Re: Dialog Box Busy
Originally Posted by VictorN
Just move the code working with the serial port into a worker thread. Use PostMessage to inform the main GUI thread about the progress bar position.
Have a look at the Using Worker Threads
Thank you, Victor,
I'll investigate this document in details in order to understand how to create a Worker Thread.
I found a temporary solution in the document: added the line "PeekMessage(&msg, NULL, 0, 0);" inside the upload processing loop and the Progress Bar is no longer freezing.
Ivan
-
March 2nd, 2014, 06:57 PM
#4
Re: Dialog Box Busy
Originally Posted by IvanCh
Thank you, Victor,
I'll investigate this document in details in order to understand how to create a Worker Thread.
I found a temporary solution in the document: added the line "PeekMessage(&msg, NULL, 0, 0);" inside the upload processing loop and the Progress Bar is no longer freezing.
Ivan
That's the simple way of solving it, kind of. I say, kind of, because you risk the chance of losing serial port data when you read the seral port in the main ui thread. This is because the user can interrupt the reading by doing something simple such as moving the mouse or dragging the dialog around. It's better to have a dedicated worker thread read the serial port as Victor suggested - then any UI operations the user performs won't get in the way of reading from the serial port.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|