That is the question. I called a function using a thread, but when I return to main control, main becomes in sleep status within a few moments.
Example (Look
here is a line that calls a Win32API function GetMessage
):
Start()
e = Thread.new { Look() }
for _i in 0..1000
puts e.status
end
This code should print the e
's status 1000 times, but it just prints once. I cannot find a reasonable error. Look
does not return until it gets a message, so I suspect that this could be causing an error.
My guess is that the status of
e
isnil
, whichputs
displays as an empty string.A
nil
status means the thread terminated abnormally.Whatever is wrong, your code is printing something 1000 times, and you should put some visible text in the
puts
to show that.Also, rather than use a throw-away variable
_i
, write