Re: Someone changed my Thread Manager writeup?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Pete Lomax wrote:
> 
> 
> Some other notes:
> There should be a built-in single procedure call for:
> }}}
<eucode>
>       if CheckThread() then
>         if QueryQuitMessage(0) then
>         end if
>         ContinueThread(TimeSlice)
>       end if
> </eucode>
{{{
</font>
> rather than having to code the whole of that in every task loop.
> 

I heartily agree.  That would make this library useful.  Here's how I'd
make it platform/library agnostic:
-- The real QueryQuit() is a function, but this requires a
-- procedure, so wrap the real thing here (users of other 
-- libs may need to do the same):
constant QUERYQUIT = routine_id("QueryQuitMessage")
procedure query_quit_message()
    if call_func( QUERYQUIT, {0}) then end if
end procedure

integer event_rid
sequence event_args

-- Set the default to use WinClass:
event_rid = routine_id("query_quit_message")
event_args = {}

-- You can make a procedure like this for any existing GUI lib
-- to make it easy:
global procedure useWin32Lib()
    event_rid = routine_id("doEvents")
    event_args = {0}
end procedure

-- Users can specify their own routine if they like:
global procedure useAny( integer rid, sequence args )
    event_rid = rid
    event_args = args
end procedure

global procedure CheckThread()
    if time() > EndSlice then
        call_proc( event_rid, event_args )
        EndSlice = time() + TimeSlice
    end if
end procedure


Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu