Long Running Program
-
I am currently working on a program which uses a GUI (written in C++ with MFC) to gather data from a user. When the user hits go, the program then analyzes the data and returns the results back to the user. The elapsed time between the time the user hits go and the results are returned is approximately 1 minute. In certain cases, it could be as high as 10 minutes. During that time, the program ignores any mouse clicks and when I bring up the Window’s task manager, the status of the program is that it is not responding. However, the calculations are complete, the program response as expected. However, for an end user, I do not believe that the program just hanging is acceptable. For example, if minimized and then restored it needs to be able to repaint the screen. What should I do to remedy the situation? I am thinking that if I did the calculation in a separate thread that it would solve this problem. What do you think of this idea? Maybe somebody knows a better way to handle this situation. Thanks Bob
-
I am currently working on a program which uses a GUI (written in C++ with MFC) to gather data from a user. When the user hits go, the program then analyzes the data and returns the results back to the user. The elapsed time between the time the user hits go and the results are returned is approximately 1 minute. In certain cases, it could be as high as 10 minutes. During that time, the program ignores any mouse clicks and when I bring up the Window’s task manager, the status of the program is that it is not responding. However, the calculations are complete, the program response as expected. However, for an end user, I do not believe that the program just hanging is acceptable. For example, if minimized and then restored it needs to be able to repaint the screen. What should I do to remedy the situation? I am thinking that if I did the calculation in a separate thread that it would solve this problem. What do you think of this idea? Maybe somebody knows a better way to handle this situation. Thanks Bob
Hi! Since the data processing procedure is running in UI thread, so no message processing operation will be performed, and that is the reason of blocking of the user interface. A simple solution is when user click the "Start" button, set the state of the UI elements (e.g. enable or disable) correctly to avoid invalid user operation and run the data operation from another thread. You can place a process bar on the form to indicat that the application is in "Busy" state while data processing is running.
-
I am currently working on a program which uses a GUI (written in C++ with MFC) to gather data from a user. When the user hits go, the program then analyzes the data and returns the results back to the user. The elapsed time between the time the user hits go and the results are returned is approximately 1 minute. In certain cases, it could be as high as 10 minutes. During that time, the program ignores any mouse clicks and when I bring up the Window’s task manager, the status of the program is that it is not responding. However, the calculations are complete, the program response as expected. However, for an end user, I do not believe that the program just hanging is acceptable. For example, if minimized and then restored it needs to be able to repaint the screen. What should I do to remedy the situation? I am thinking that if I did the calculation in a separate thread that it would solve this problem. What do you think of this idea? Maybe somebody knows a better way to handle this situation. Thanks Bob
-
I am currently working on a program which uses a GUI (written in C++ with MFC) to gather data from a user. When the user hits go, the program then analyzes the data and returns the results back to the user. The elapsed time between the time the user hits go and the results are returned is approximately 1 minute. In certain cases, it could be as high as 10 minutes. During that time, the program ignores any mouse clicks and when I bring up the Window’s task manager, the status of the program is that it is not responding. However, the calculations are complete, the program response as expected. However, for an end user, I do not believe that the program just hanging is acceptable. For example, if minimized and then restored it needs to be able to repaint the screen. What should I do to remedy the situation? I am thinking that if I did the calculation in a separate thread that it would solve this problem. What do you think of this idea? Maybe somebody knows a better way to handle this situation. Thanks Bob
try "sleep(0)" this will make windows execute its message queue here's msdn explanation: A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE indicates that the suspension should not time out.
-
try "sleep(0)" this will make windows execute its message queue here's msdn explanation: A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE indicates that the suspension should not time out.
dehseth wrote:
try "sleep(0)" this will make windows execute its message queue
Actually it won't. You still need to manually flush the message queue by calling
PeekMessage()
in order to convey the impression of multi-threading. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com