Skip to content

Commit

Permalink
finish Task
Browse files Browse the repository at this point in the history
  • Loading branch information
MandelV committed Dec 6, 2018
1 parent 0299b67 commit bdd1ca8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
13 changes: 13 additions & 0 deletions Model/ITask.cs
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();
}
}
37 changes: 26 additions & 11 deletions Model/Task.cs
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; }
}
}

0 comments on commit bdd1ca8

Please sign in to comment.