Forums

Thread Example

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Thread Example

Postby Charles » Mon Feb 11, 2008 2:31 pm

Okay, it's a silly example, but it shows another use of "ref" for referring to methods instead of invoking them:
use System.Threading

class ThreadTest

shared

var _maxSeconds = 2.1f
var _start as DateTime

def main
_start = DateTime.now
t = Thread(ref .writeY)
t.start
while not .isFinished
print 'a' stop
t.join
print
print 'Finished.'

def writeY
while not .isFinished
print 'b' stop

get isFinished as bool
return DateTime.now.subtract(_start).totalSeconds >= _maxSeconds
Charles
 
Posts: 2515
Location: Los Angeles, CA

Return to Discussion

Who is online

Users browsing this forum: No registered users and 26 guests