Forum C# ScheduleCallback seems unreliable

ScheduleCallback seems unreliable

Postby mfranzs » March 29th, 2011, 8:31 pm

Okay... so, ScheduleCallback seems RIDICULOUSLY unreliable.

If I set trig to 281, and run:

Code: Select all
timer = ScheduleCallback(delegate { this.onTick(); }, trig);


Then I have onTick() running in 52 seconds, or in 65 seconds, or in 71 seconds, etc.

This happens every time..

Why is this so unpredictable? Any ideas?
mfranzs
 
Posts: 98
Joined: August 29th, 2010, 3:27 am

Re: ScheduleCallback seems unreliable

Postby Oliver » April 15th, 2011, 11:41 am

I can't reproduce your error.

With this code:

Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using PlayerIO.GameLibrary;
using System.Drawing;

namespace MyGame {
   public class Player : BasePlayer {
      public string Name;
   }

   [RoomType("MyCode")]
   public class GameCode : Game<Player> {
      // This method is called when an instance of your the game is created
      public override void GameStarted() {
         var now = DateTime.UtcNow;
         ScheduleCallback(delegate {
            Console.WriteLine( (DateTime.UtcNow - now).TotalMilliseconds  + "ms");
         }, 281);
      }
   }
}


I get this result:

Code: Select all
=====[  Room Started: MyCode  ]==========
>User bob (1): Joined game
280.0004ms


Which is really precise, only off by 1 ms.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to C#



cron