Re: To Insolor and those interested in dos rescue programme

new topic     » goto parent     » topic index » view thread      » older message » newer message
useless_ said...
Insolor said...
for i = 1 to 3750000 do
    task_yield() 
end for 


This doesn't look like the proper way to use tasks, but i don't know what you are trying to do. What are you trying to do?

useless

In DOS age the common practice was to make pause with empty loops.

The problem here is that dos rescue library has a background task that handles windows' messages to the main window procedure. To allow the window response on events the main task must yield execution to the background task from time to time (at least every 100ms), so it's highly recomended to add task_yield() explicitly to such empty loops. Loops like `while get_key()<0 do end while` do not need task_yield() because the dosrescue's get_key() calls task_yield() itself:

override function get_key() 
-- override Euphoria built-in 
-- get next character sent to graphics window 
    integer c 
    if not window_ready then 
        return eu:get_key() 
    else 
        task_yield() 
        if length(char_buff) = 0 then 
            c_proc(Sleep,{delay}) 
            return -1 
        else 
            c = char_buff[1] 
            char_buff = char_buff[2..$] 
            return c 
        end if 
    end if 
end function 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu