Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Commented Unassigned: setTimeout fails after upgrade [93]

0
0
I just upgraded from version 5.4.2 to 5.4.3 and script code that once worked now fails with the error "Object doesn't support this property or method". I am using V8.

I added a host object that is a Timer
```
Engine.AddHostType("ScriptTimer", GetType(ScriptTimer))
```

My ScriptTimer looks like this (VB.Net)
```
Public Module ScriptTimer
Public Function Create(func As Object, delay As Double, period As Double, args As Object)
Try
Dim callback As System.Threading.TimerCallback = New System.Threading.TimerCallback(
Sub()
Try
func.apply(Nothing, args)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub)
Return New System.Threading.Timer(callback, Nothing, Convert.ToInt64(delay), Convert.ToInt64(period))
Catch ex As Exception
Console.WriteLine(ex.Message)
Return ex
End Try
End Function
End Module
```

And this is the script that fails.
```
function createTimer(periodic, func, delay) {
var period = periodic ? delay : -1;
var args = Array.prototype.slice.call(arguments, 3);
return ScriptTimer.Create(func, delay, period, args);
}

setTimeout = createTimer.bind(null, false);
```
Comments: Hello! Hmm, we can't reproduce this. Can you post a call stack? Here's the full program we ran without encountering any issues: ``` VB.NET Imports Microsoft.ClearScript.V8 Public Module ScriptTimer Public Function Create(func As Object, delay As Double, period As Double, args As Object) Try Dim callback As Threading.TimerCallback = New System.Threading.TimerCallback( Sub() Try func.apply(Nothing, args) Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub) Return New Threading.Timer(callback, Nothing, Convert.ToInt64(delay), Convert.ToInt64(period)) Catch ex As Exception Console.WriteLine(ex.Message) Return ex End Try End Function End Module Module Module1 Sub Main() Using engine As New V8ScriptEngine engine.AddHostType("ScriptTimer", GetType(ScriptTimer)) engine.Execute( <![CDATA[ function createTimer(periodic, func, delay) { var period = periodic ? delay : -1; var args = Array.prototype.slice.call(arguments, 3); return ScriptTimer.Create(func, delay, period, args); } setTimeout = createTimer.bind(null, false); ]]>.Value) End Using End Sub End Module ``` Thanks!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images