public IJSValue CreateTimer(IJSContext context, int milliSeconds, IJSValue action) { var r = new TimerRegistration { }; Device.StartTimer(TimeSpan.FromMilliseconds(milliSeconds), () => { action.InvokeFunction(null, context.CreateNumber(r.Value)); r.Value++; return(!r.Disposed); }); // this will be disposed inside JavaScript return(context.CreateDisposableAction(() => { r.Disposed = true; })); }