Hello everyone.
When testing the Jscript.NET on the .NET 2.0 Beta 2 (JScript
8.00.50215), I found an older example, with a FileSystemWatcher thread
example.
below is the example
// ----- file 'watcher.js' -----
import System.Threading;
import System.IO;
// Placeholder class to hold the delegate (callback)
class Delegates {
static function Handler(o : Object, e : FileSystemEventArgs) {
print(e.FullPath);
// Stop when a file including the word "quit" is created
if (e.FullPath.indexOf("quit") >= 0) {
keepGoing = false;
}
}
static function Main() {
// Create the directory listener
var w : FileSystemWatcher = new FileSystemWatcher("c:\\temp",
"*.txt");
// Add the event handler (ignore compiler warning)
w.add_Created(Handler);
//w.Enabled = true;
// Sleep a while and see if it is time to quit
while(keepGoing)
Thread.Sleep(500);
}
}
// Start off a new thread to keep the process alive
var keepGoing = true;
new Thread(Delegates.Main).Start();
// ----- Command Line -----
Well, this was supposed to give a warning message for the "add_Created"
part. It now doesn't, although it complains about w.Enabled o existent.
HOWEVER, on the last line, "new Thread(Delegates.Main).Start();" I get
the following compiler error:
JS1184: More than one constructor matches this argument list
I looked in the error descriptions, but I can't figure out why this
happens. Any help would be appreciated.
Also, below is the link to the older message( where I got the source
code from)
http://groups.google.com/group/microsoft.public.dotnet.languages.jscript/browse_
thread/thread/6688cf1e3ad718e1/65de20cfd1fe3fa7?q=new+Thread(Delegates.Main).Sta
rt();&rnum=1&hl=en#65de20cfd1fe3fa7
Regards,
Andrei
Serge Baltic - 24 Aug 2005 13:55 GMT
Hello,
a> HOWEVER, on the last line, "new Thread(Delegates.Main).Start();" I
a> get the following compiler error:
a>
a> JS1184: More than one constructor matches this argument list
a>
a> I looked in the error descriptions, but I can't figure out why this
a> happens. Any help would be appreciated.
I've had the same problem. AFAIR that happened due to new overloads of the
Thread..ctor method introduced to the 2.0 version of the .NET framework,
so the JScript compiler cannot tell between them any more. You may fix this
problem by adding an explicit typecasting, or something like that — that's
how I made it.
(H) Serge