- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
the subject names my question: Is it possible to create a multithreaded QuickWin application? There is no entry for that type of project in my project properties (Fortran -> Libraries, IVF10, VS2003) andtyping /libs:qwin /threads manually wont work. Or is QuickWin a multithread application from the start?
Basicly I want to run my calculationand my plotting routines in different threads. Is that possible in a QuickWin application in general?
Thanks in advance,
Markus
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A QuickWin program is already multithreaded. Take a look at the sample programs and you will see that, after setting up any menu modifications that are wanted, the 'main' program contains an infinite do-nothing loop, which does not tie up all resources and halt thingsbecause the main work of handling menu callbacks is being done in another thread.
It would be straightforward to have a 'Calculate' menu item create a new thread which, when finished, puts up an informative message box to that effect and then terminates itself.
Data can be shared between the plotting routines and the computation thread using modules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Of course you have to supply the code to start a thread, but this is fairly easy. You use CreateThread, for example:
module ThreadGlobals
!allows storage of thread handles etc. and any other data
! that the main program may need to send to and get from the thread
INTEGER*4 HTHREAD, IDTHREAD
! Declare your variables that will be filled with your computed data
REAL(8) X(1000),Y(1000),Z(1000)
INTEGER(4) NUMVALUES
..etc..etc..
end module
SUBROUTINE MYCALLBACK(DLG,ID,CALLBACKTYPE)
...
USE THREADGLOBALS
integer(4) threadarg
..
threadarg=1 ! argument suppliedto ThreadFunc. User selects the value. Doesn't have to be used
HTHREAD=CreateThread(0,0,loc(THREADFUNC),threadarg,0,idthread)
.....
END SUBROUTINE MYCALLBACK
INTEGER(4) FUNCTION THREADFUNC(arg)
!Function containing the code to be executed in the thread
!DEC$ ATTRIBUTES VALUE :: arg
USE THREADGLOBALS
integer(4) arg
...
...add your computation code here...
...
THREADFUNC= 1! Sets exit code to 1
RETURN !The thread is automatically terminated after it returns
END FUNCTION THREADFUNC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Anthony,
I will try that when I have time for it...
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Along the following lines:
In the program:
DO WHILE (.TRUE.)
IF (bWakeUp) THEN
!Long lasting calculation
bWakeUp = .FALSE.
ELSE
CALL SLEEPQQ(0)
END IF
END DO
In some menu callback for calculation, simply set global bWakeUp to .TRUE. (and set up other parameters for calculation, if necessary). Also take care to disable UI items which could cause havoc if clicked during the process (e.g. user changes parameters in the midst of calculation).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page