Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: yaobifeng on August 19, 2008, 10:29:15 AM

Title: how to create ourself's Async methods?
Post by: yaobifeng on August 19, 2008, 10:29:15 AM
The engine has some Async methods,can we define it by  ourself?thanks. :)
Title: Re: how to create ourself's Async methods?
Post by: Mnemonic on August 19, 2008, 02:44:07 PM
You mean methods that return immediately and run in a separate thread? That currently isn't possible. You can simulate this using events, but of course, events don't have parameters.

Code: WME Script
  1. this.ApplyEvent("parallel_task");
  2. // some code 1
  3.  
  4. on "parallel_task"
  5. {
  6.   // some code 2
  7. }
  8.  

Some code 1 and some code 2 will run in parallel after executing this script.
Title: Re: how to create ourself's Async methods?
Post by: yaobifeng on August 19, 2008, 03:30:20 PM
You mean methods that return immediately and run in a separate thread? That currently isn't possible. You can simulate this using events, but of course, events don't have parameters.

Code: WME Script
  1. this.ApplyEvent("parallel_task");
  2. // some code 1
  3.  
  4. on "parallel_task"
  5. {
  6.   // some code 2
  7. }
  8.  

Some code 1 and some code 2 will run in parallel after executing this script.
thanks very much,i think that's enough.i will try it later.