Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I'm running a Visual C++ program which by its nature has to spend hours calculating and meanwhile not interacting with Windows. This isn't a mistake - just a long calculation. Windows 7 interprets this as "not responding". How can I fix it so Windows doesn't give up while the program is still number crunching? Many thanks in anticipation. Be kind, I'm an idiot!
Posted

This is absolutely normal behavior in this situation. You should do only one thing: use threading.
—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 10-Mar-11 15:28pm    
Right :)
Sergey Alexandrovich Kryukov 10-Mar-11 15:48pm    
Thank you.
--SA
If your calculation takes several hours - take a serious look at
CUDA and CUBLAS[^] - for a typical number crunching application - an iterative solver - it ought to do wonders.

Here is some info on what you may expect to gain
http://www.tomshardware.com/reviews/nvidia-cuda-gpgpu,2299.html[^]

Obviously, moving your number crunching to another thread, as SAKryukov suggests, is a good thing to do, and even splitting it, if possible, among multiple cores using multiple threads. This may require a significant amount of redesign - or if your lucky - simply deviding the iterations of the outer loop between the threads.

You may find that ACE[^] has the C++ classes required to facilitate this move in a very elegant manner.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Nuri Ismail 11-Mar-11 3:03am    
Good advices, Espen. My 5.

P.S. I don't understand why sometimes good answers like this are downvoted. :(
Espen Harlinn 11-Mar-11 4:20am    
Thank you Nuri Ismail!
Sergey Alexandrovich Kryukov 11-Mar-11 12:46pm    
Interesting references, my 5.
--SA
Espen Harlinn 11-Mar-11 13:20pm    
Thank you, SAKryukov!
Just make your calculations in a worker thread. An excellent resource on worker threads[^]. :)

If you need further assistance you have to share more details about your application.
Is it GUI or Console application, does it use MFC, even you can post relevant parts of your code, these details are all welcome. :)
 
Share this answer
 
v2
Comments
Yusuf 10-Mar-11 15:31pm    
Excellent
Nuri Ismail 11-Mar-11 2:53am    
Thank you, Yusuf!
Espen Harlinn 11-Mar-11 4:21am    
Good reply, nice link :)
Nuri Ismail 11-Mar-11 5:06am    
Thank you! :)
maybe this help ?

http://forums.devx.com/archive/index.php/t-91311.html[^]


or this : ?

C#
void DoEvents()
{
    MSG msg;
    long sts;
    do {
    if (sts = PeekMessage(&msg, (HWND) NULL, 0, 0, PM_REMOVE)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    } while (sts);
}


insert it in some place in your code ...

example :

...
...
while(...)
{
   ...
   ...
   DoEvents();
}
...
for(...)
{
   ...
   ...
   DoEvents();
}


... whill be there some loop in your calculation ? that is cpu expensive, insert DoEvents to Release control to windows
 
Share this answer
 
v5
Comments
Sergey Alexandrovich Kryukov 10-Mar-11 11:00am    
Piccadilly, please look at this reference yourself and answer a simple question: how do you think, shall OP use DoEvents or something else? It is not clear...
--SA
Nuri Ismail 10-Mar-11 11:02am    
Piccadilly, I think that the separate worker thread solution is better.
Have a look at the link in my answer ('Doing it the obsolete, and hard, way' section from the linked article) for additional details.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900