Forum C# Timer breakage !!!!!

Timer breakage !!!!!

Postby tadeegan » May 17th, 2010, 9:07 pm

Hey guys, i created a timer this is my code:
Code: Select all
public GameCode(){
     
            this.ScheduleCallback(OnTimedEvent, 25);
        }
        public void OnTimedEvent()
        {
            Console.WriteLine("Hello World!");
        }

GameCode is a constructor.
I get the error: SocketConnection.ReceivedBytes ERROR: Exception has been thrown by the target of an invocation., Appdomain: Test Server.vshost.exe
when i try to connect to it.
Any ideas?
tadeegan
 
Posts: 5
Joined: April 22nd, 2010, 10:24 pm
Location: Michigan

Re: Timer breakage !!!!!

Postby Oliver » May 18th, 2010, 4:42 pm

Hi,

Could you post some more details ? perhaps the full code listing for the serverside code?

The schedulecallback thing should not cause the exception you're seeing.

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

Re: Timer breakage !!!!!

Postby tadeegan » May 18th, 2010, 8:59 pm

I got it to work. I dont know why but when I moved the this.ScheduleCallback(OnTimedEvent, 25); out of the constructor and into the GameStarted() function it worked. Weird.
tadeegan
 
Posts: 5
Joined: April 22nd, 2010, 10:24 pm
Location: Michigan

Re: Timer breakage !!!!!

Postby Oliver » May 19th, 2010, 11:56 am

Ah... you're not supposed to have code in the constructor.. We haven't ever actually done any testing for this case however.

Thanks for finding it :-)

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

Re: Timer breakage !!!!!

Postby tadeegan » May 19th, 2010, 2:27 pm

:D my game is looking pretty sweet. http://www.keithlemmons.com/index.php?p=2_18
tadeegan
 
Posts: 5
Joined: April 22nd, 2010, 10:24 pm
Location: Michigan

Re: Timer breakage !!!!!

Postby nirza » May 19th, 2010, 5:43 pm

nice!
it seems the circles doesn't always get painted when near them.
nirza
 
Posts: 39
Joined: April 10th, 2010, 11:50 am


Return to C#



cron