Do with it whatever you want. Feel free to ask any question(s).
TimerTaskExecutor executor = new TimerTaskExecutor(); TimerTask task = new TimerTask(execute); task.setWaitTime(2000); executor.ExecuteTimerTask(task);
new TimerTaskExecutor().ExecuteTimerTask(new TimerTask(execute) { sleepTime = 2000 });
public int sleepTime { get { return _waitTime; } set { _waitTime = value; } }
Wouldn't make a difference you're still creating new instances. Besides, the wait times aren't ment to be changed after being set.. so yeah.Quote:
Looking neat bro. For those who wants to keep things cleaner, for the initializing part.
Instead of
You could simply just:Code:TimerTaskExecutor executor = new TimerTaskExecutor(); TimerTask task = new TimerTask(execute); task.setWaitTime(2000); executor.ExecuteTimerTask(task);
+TimerTask.cs:Code:new TimerTaskExecutor().ExecuteTimerTask(new TimerTask(execute) { sleepTime = 2000 });
Code:public int sleepTime { get { return _waitTime; } set { _waitTime = value; } }
Keep it up bro!
Yeah, ofcourse, but what I was aiming for was if you're going to have a set of threads/timers (possibly not for CO, but for other applications as this is not CO related really), it'd be easier to manage and organize the initialization the way I suggested - both works the same just saves a couple of rows.Quote:
Wouldn't make a difference you're still creating new instances. Besides, the wait times aren't ment to be changed after being set.. so yeah.
TimerTaskExecutor executor = new TimerTaskExecutor();
TimerTask task = new TimerTask(execute);
task.setWaitTime(2000);
executor.ExecuteTimerTask(task);
new Thread(Core).Start();
void Core()
{
if (LastCheck.AddMili <= CurrentTime)
{
LastCheck = CurrentTime;
blabla
}
Who said it is co related? However, you could easily implement this into a co environment.Quote:
Yeah, ofcourse, but what I was aiming for was if you're going to have a set of threads/timers (possibly not for CO, but for other applications as this is not CO related really), it'd be easier to manage and organize the initialization the way I suggested - both works the same just saves a couple of rows.
TimerTask staminaTask = new TimerTask(client, execute);
staminaTask.setWaitTime(2000);
executor.ExecuteTimerTask(staminaTask);
static bool execute(object targObj, DateTime timeofExecution)
{
//update stamina perhaps?
Console.WriteLine("Executed!");
return true;
}
Was meant to ask, Why make "client" an object when a foreach loop is just as easy.Quote:
Who said it is co related? However, you could easily implement this into a co environment.
Code:TimerTask staminaTask = new TimerTask(client, execute); staminaTask.setWaitTime(2000); executor.ExecuteTimerTask(staminaTask); static bool execute(object targObj, DateTime timeofExecution) { //update stamina perhaps? Console.WriteLine("Executed!"); return true; }