Forum C# Runing Timer Forever

Runing Timer Forever

Postby kidkid » December 9th, 2010, 9:23 am

Hi,
Currently I am developing a flash game. In that, I will check time for do some events.
let say I have 10 questions for player to answer in a day.
these questions will change every day
so I need a timer to check that.

I have used attachtimer but when no user join.
The timer will be close.

Could I make a timmer for run forever ?

Otherwise, I am thinking about save the time to database, so whenever user join, I could read the database to compare the time, and make new question.

Thanks.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Runing Timer Forever

Postby TobiasW » December 9th, 2010, 10:06 am

Hey,

kidkid wrote:Otherwise, I am thinking about save the time to database, so whenever user join, I could read the database to compare the time, and make new question.


that's the way to do it, since the changing of questions is only needed upon user action.

Cheers,
Tobias
User avatar
TobiasW
 
Posts: 59
Joined: August 29th, 2010, 12:31 am

Re: Runing Timer Forever

Postby kidkid » December 9th, 2010, 11:02 am

Hi thanks,
But I have another problem like that:

at the time of userbirthday, We should send them a gif. So how could I implement in this case ?
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Runing Timer Forever

Postby Oliver » December 16th, 2010, 1:25 pm

Currently there is no way to schedule code to run at a predefined time OUTSIDE the context of a live room on Player.IO.

The two solutions available are:
a) Save a timestamp in BigDB, and process everything since the timestamp when a user creates a room
b) Have some code running externally (using the .NET Client or the AS3 Client) that periodically creates a room that will execute your code for you.

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

Re: Runing Timer Forever

Postby kidkid » December 17th, 2010, 8:36 am

Hi Oliver,
Thank for your quick answer my private message and reply my above post.

I has decided to use .Net Client which will running in windows service to solve that problem.
Thanks for your reply again.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Runing Timer Forever

Postby rambert » January 22nd, 2011, 1:22 am

Oliver wrote:b) Have some code running externally (using the .NET Client or the AS3 Client) that periodically creates a room that will execute your code for you.


Does this means, that the server code is terminated when the last player left the game and there is no way to keep the server running if nobody is online?

Is there a maximum execution time for the method "public override void GameClosed()"? Is there a way to delay the end of the server termination by a time?

Rambert
rambert
 
Posts: 5
Joined: April 12th, 2010, 5:19 pm

Re: Runing Timer Forever

Postby Oliver » January 24th, 2011, 12:17 pm

Does this means, that the server code is terminated when the last player left the game and there is no way to keep the server running if nobody is online?


Well.. It means that a room instance is closed when the last person leaves the room. The server software will still be running, it just won't be running your code.

Is there a maximum execution time for the method "public override void GameClosed()"? Is there a way to delay the end of the server termination by a time?


Yes: 100ms. You can't delay it. When the last person leaves the room, the room will be closed. You can't run code outside the context of a room. If you want to do so, you should look at the two suggestions from my earlier post in this thread :-)

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


Return to C#



cron