- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you change the cursor to an hourglass while a long calculation is being performed?Also, is it possible to estimate the length of time the calculation will require and display this estimate before beginning?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you change the cursor to an hourglass while a long calculation is being performed?Also, is it possible to estimate the length of time the calculation will require and display this estimate before beginning?
No, I do not change the cursor to an Hourglass. It is not straitforward to estimate the time for calculation.
The Problem is, I have a Progress bar, which should show the Progress, but however, sometimes, the Progress bar does not update the displaying, and If I click on my Aplication or on the Progress bar. The cursor change to the Hourglass and says "Not responding". It would be nice, to know, the actual progress state,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, I do not change the cursor to an Hourglass. It is not straitforward to estimate the time for calculation.
The Problem is, I have a Progress bar, which should show the Progress, but however, sometimes, the Progress bar does not update the displaying, and If I click on my Aplication or on the Progress bar. The cursor change to the Hourglass and says "Not responding". It would be nice, to know, the actual progress state,
The cause is as follows: your application cannot do two things at the same time without additional threads -- while you're doing the number crunching, your application windows do not redraw themselves. To observe an even worse effect, do an Alt+Tab or drag another window over your application's while the calculation is running. Other menus don't work etc.
Your callbacks, in general, should be quick, to allow the application to be responsive
There are several ways to overcome the problem:
* QuickWin alrady has two threads -- the "secondary" one runs within the PROGRAM. You can move the calculating code from the callback there (rather than just doing nothing in the loop), and just "raise" a flag when calculation should be started/stopped
* Google "ThreadDlg"
* Call PeekMessage in a loop every while during the calculation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The cause is as follows: your application cannot do two things at the same time without additional threads -- while you're doing the number crunching, your application windows do not redraw themselves. To observe an even worse effect, do an Alt+Tab or drag another window over your application's while the calculation is running. Other menus don't work etc.
Your callbacks, in general, should be quick, to allow the application to be responsive
There are several ways to overcome the problem:
* QuickWin alrady has two threads -- the "secondary" one runs within the PROGRAM. You can move the calculating code from the callback there (rather than just doing nothing in the loop), and just "raise" a flag when calculation should be started/stopped
* Google "ThreadDlg"
* Call PeekMessage in a loop every while during the calculation.
I Tried the mehod using PeekMessage. I don't like the method, using this Thread stuff (similar in ThreadDlg), because I have several longer Computations, which would require a lot of rewriting, and they are parallized routines. So I'm not sure if the method with Thread will work.
At the beginning It worked, but, when I added a Stop button, the Peek_Message loop never retured.
What ist the problem ? If I remove the"DlgSetSub(dlg, IDC_PROGRESS_STOP, Update_Progress)" , than the loop returns. But, the Subroutine Update_Progress, where I check if the Stop button was pressed, is never called.
Generally I do the following, at the beginning of a long computation I Initialize the Progress_bar, During computation I call the Progress_bar to update the progress. It works fine, but if I use the Stop Button subroutine, the Loop never returns. In the message msg, during the loop is always the same value. So I tried to skip out of the loop, after a certain time passed. However the Subroutine Update_Progress is never called.
subroutine Progress_Bar(init_flag, progress)
if (init_flag .EQ. 1) then
retlog=DlgInit(IDD_Progress_Dlg,dlg)
retlog=DlgSetSub(dlg, IDC_PROGRESS_STOP, Update_Progress)
retlog=DlgModeless(Dlg_prog)
else
retlog=DlgSet(Dlg,IDC_PROGRESS_BAR, progress,DLG_POSITION)
retlog = .TRUE.
do while (retlog)
retlog=PeekMessage(msg,hwnd,0,0, PM_REMOVE)
enddo
endif
end subroutine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the OP's situation relates more to how to use Windows than to Fortran, and the problem is compounded by using Quickwin. The way to have a live progress bar track a long computational loop is--
1) put the computation in a separate thread from the main program
2) the program needs to manage its own Windows message loop (sorry, no Quickwin)
3) Prior to the start of computation, a progress-bar dialog is created as a child to the main window
4) add a Windows timer to the main program loop, which will send a Windows message to the progress-bar dialog at some defined interval, say every 500 msec.
5) when the progress-bar dialog gets a timer ping, it updates the visual state of the progress-bar control by referencing the (module-scoped, and hence accessible) computation progress variable
Note that this architecture also facilitates having live buttons to stop or pause the computation, as part of the progress-bar dialog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
QuickWin isa dumb down library that hasn'tbeen supported for eons. Perhaps it's time to bite the bullet and try your hand at .NET if you are not Windows APIinclined. BTW, the tips given by Jugoslav and Paul are bang on.
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
QuickWin is supported, but I'll agree that it is not as capable as using the Win32 API directly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
QuickWin may be supported by Intel but not so bythe vendor (MS). It's deemed to have outlived its original purpose by a decade or so.
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I Tried the mehod using PeekMessage. I don't like the method, using this Thread stuff (similar in ThreadDlg), because I have several longer Computations, which would require a lot of rewriting, and they are parallized routines. So I'm not sure if the method with Thread will work.
do while (retlog)
retlog=PeekMessage(msg,hwnd,0,0, PM_REMOVE)
enddo
I didn't mean "Call PeekMessage in a loop" that literally :-).
Here's an example of "asynchronous message loop" I meant:
http://software.intel.com/en-us/forums/showpost.php?p=13555
Jugoslav
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page