-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Model | ||
{ | ||
public interface ITask | ||
{ | ||
void exec(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Model | ||
namespace Model | ||
{ | ||
public delegate T callback<T>(List<T> param); | ||
public class Task<T> | ||
public delegate T callback<T>(params object[] param); | ||
public class Task<T> : ITask | ||
{ | ||
private List<T> param; | ||
public readonly object[] Param; | ||
public readonly callback<T> Callback; | ||
private int tickRemaining; | ||
private callback<T> callback; | ||
|
||
public Task(object[] param, callback<T> callback, int numberTicks) | ||
{ | ||
tickRemaining = numberTicks; | ||
Callback = callback; | ||
Param = param; | ||
} | ||
|
||
public void exec() | ||
{ | ||
if (tickRemaining == 0) | ||
{ | ||
Callback.Invoke(Param); | ||
} | ||
else | ||
{ | ||
tickRemaining--; | ||
} | ||
|
||
} | ||
|
||
public int TickRemaining { get => tickRemaining; } | ||
} | ||
} |