|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
Welcome everyone, since I had a busy night, I came across some strange problem. I have a program which does a looooot of calculations. Lots means a couple of hours. After five seconds, the program stops responding and becomes a resident in the system, but works correctly in the background, since the generated output files are correct and keep on growing. The problem is that I want to show user that the program is actually working OK, and I cannot do it when the program window does not respond. Is there any way of forcing refresh on the window? I tried Invalidate() but does not seem to have too much effect on it. Can anyone at least try to help with that? It is not very important but I would liek to know that. Thanks for posts Marek |
|
#2
|
|||
|
|||
|
I'm assuming you're using mfc or win32. Either way, ui updates only occur when your program enters idle states, which won't happen if you're program is churning away calculations for hours without end.
One solution is to break up the calculations, restarting them on consecutive idle messages. Another is to begin a slave thread, which runs independent of the ui thread. |
|
#3
|
||||
|
||||
|
So what You are saying is there is no way to do that without breaking up the flow of calculations. The problem is that there is no way of breaking them up. If I do that, I would have to store a lot of intermediate results in the memory, much too much to be honest.
Could You give some details about this slave thread? I have heard nothing about that so far. Thanks Marek |
|
#4
|
||||
|
||||
|
Quote:
It's called Multithreaded Programming. Look up CWinThread under MFC or pthreads (POSIX threads) under Linux. Most of the concepts are the same between the two, but the actual function names and syntax are different. We will need to know which OS and development system you are using to be able to be more specific. |
|
#5
|
||||
|
||||
|
Hello
when it comes to the operation system it is win2000 for now. I have been obliged to use it since the end user (that is my university professor has it installed). If thsi is no problem, just let me know what kinda of function to look for, I think I will be able to handle this once I know what to look for specifically. Thanks Best greets Marek |
|
#6
|
|||
|
|||
|
CWinThread is the mfc class you're looking for, it encapsulates the calls to win32 api to create threads. Also lookup AfxBeginThread, which creates a thread and begins it's execution, and AfxEndThread, which can be used from within the thread to end execution.
I can't offer much advice though, I've never written a 'real' multithreaded program, just excercies. |
|
#7
|
||||
|
||||
|
Nevertheless, thanks a lot. Now I know what to look for. It is going to be much easier.
Best greets MArek |
|
#8
|
|||
|
|||
|
Quote:
Isnīt there an ::Update() method? If not, try sending WM_PAINT to the window regularly...
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#9
|
||||
|
||||
|
Well, I am going to test it out in a few minutes, if it works, it is going to be muuuuch easier than creating threads, I began to read about that and honestly - there has to be easier way to do that.
Thanks for the post Best greets MArek ![]() |
|
#10
|
||||
|
||||
|
wel I tried to find the Update() method but in vain. There is no such method avaliable or I caanot find it. Either way, perhaps You have some more details on it ? At least where I could find it?
Thanks for posts Best greets MArek |
|
#11
|
|||
|
|||
|
Try UpdateWindow.
|
|
#12
|
|||
|
|||
|
UpdateWindow is a member of CWnd and CWindow.
I doubt sending a WM_PAINT message will work. If I remember the Windows message queue model correctly, the queue is read on idle states, which of course won't happen until you're large calculation process returns. Similarly, all UpdateWindow does is dump a WM_PAINT message into the queue, so it won't be any different than the sending a message. Let us know though, if it works. Last edited by MJEggertson : April 2nd, 2003 at 01:10 PM. |
|
#13
|
|||
|
|||
|
Found this method though: CWnd::RedrawWindow.
It seems to force an immediate redraw of a given area. That is, it doesn't send WM_PAINT messages, it does an actual draw operation. May work. |
|
#14
|
|||
|
|||
|
The message queue will only be read when the app goes idle?
How can a SendMessage() return values then? It has to wait for a message to be processed -> the calling thread will be stopped and the program will be idle. This description could be wrong, but the effect is iirc the same. AFAIK PostMessage() is the function that will not block the calling thread. Wrong? |
|
#15
|
|||
|
|||
|
Right, my bad. I was thinking PostMessage. Heh...phew....time for lunch.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Program window does not refresh. What is wrong ??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |