开发者

Instantiating a System.Threading.Thread object in Jscript

I'm trying to create a new System.Threading.Thread object us开发者_如何转开发ing Jscript, but I can't get the constructor to work. If I just do the following,

var thread = new Thread( threadFunc );

function threadFunc() {
    // do stuff
}

then I get error JS1184: More than one constructor matches this argument list.

However, if I try to coerce threadFunc to System.Threading.ThreadStart via

var thread = new Thread( ThreadStart(threadFunc) )

I get error JS1208: The specified conversion or coercion is not possible

Anyone know how to do this? It seems like it should be trivial.


Wrap it in a class, it should work.

import System;
import System.Threading;

class MyClass {
    static function threadFunc() { Console.WriteLine("threadFunc"); }
}

var thread = new Thread( ThreadStart(MyClass.threadFunc) );
thread.Start();
thread.Join();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜