Hi Miguel,

First, as far as I know, it is impossible to do multi-thread using Lingo.
However, it is possible to do multi-thread using Xtras beacause Xtras are
made with C/C++ and Win* allows to do multi-thread application (for
examples, see beginthread in MSDN).

There is a way to simulate multi-thread in Director. It is not real
multi-threading and it's going to work in the Director's thread, I call it
more "call-back functions". For example, you can use the "idle" method and a
stack (ie: a priority list) to store the working functions. I don't think
it's useful to do that since it's not real multi-threading... Anyway, here
is an example:

-- Global script

global myStack

on startMovie
  
  -- You can dynamically fill this list which is the stack.
  myStack = [[#wrk: "wrkFct1()", #cb: "cbFct1()"], [#wrk: "wrkFct2()", #cb:
"cbFct2()"]]
  
  -- You can eventually use priority. If you want a method to be executed
first, put it 
  -- in the beginning of the list (HIGH PRIORITY) and vice-versa.
  
end startMovie

on idle
  
  if myStack <> [] then
    do string(myStack.getAt(1).getProp(#wrk))
    do string(myStack.getAt(1).getProp(#cb))
    myStack.deleteAt(1)
  end if
  
end idle

on wrkFct1
  
  a = 1
  b = 5
  return a + b
  
end wrkFct1

on cbFct1
  
  put "Thread 1 done!"
  
end cbFct1

on wrkFct2
  
  a = 4
  b = 6
  return a + b
  
end wrkFct2

on cbFct2
  
  put "Thread 2 done!"
  
end cbFct2 

on addThread1
  
  myStack.add([#wrk:"wrkFct1()", #cb:"cbFct1()"])
  
end addThread1

on addThread2
  
  myStack.add([#wrk:"wrkFct2()", #cb:"cbFct2()"])
  
end addThread2

-- End script

It is obvious that it's not real multi-thread, but it should work fine as a
"workaround".

Have a nice day,
Jonathan

> -----Original Message-----
> From: Miguel Gonzalez [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 26, 2001 8:01 AM
> To: [EMAIL PROTECTED]
> Subject: <lingo-l> Multi tread with Lingo
> 
> 
> Hi all.
> 
> Does anybody know any example about how to do something 
> similar to a multi
> tread code?
> 
> Lingo is not a multitread language, but maybe anybody knows how to do
> something similar.
> 
> Thanks in advance.
> 
> 
> Miguel.
> 
> 
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
> 

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to