1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
public class Flagger
{
public Dictionary<string, bool> flags = new Dictionary<string, bool>();
private List<Action> actions = new List<Action>();
public event System.EventHandler Completed;
public void Add(Action ExecuteAfter)
{
this.flags.Add(ExecuteAfter.Method.Name, false);
actions.Add(ExecuteAfter);
}
public void Run()
{
foreach (Action c in actions)
{
c.Invoke();
}
}
public void Clears()
{
this.flags.Clear();
}
public void Set(string flagName)
{
lock (this.flags)
{
this.flags[flagName] = true;
foreach (bool value in this.flags.Values)
{
if (value == false)
{
return;
}
}
}
// tout le monde a terminé
if (Completed != null)
{
this.Completed(this, null);
}
}
} // fin classe |