Verrou non bloquant
This commit is contained in:
parent
9c41df3665
commit
b5fc4fda64
2 changed files with 40 additions and 32 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -321,27 +322,31 @@ namespace DMX2
|
||||||
|
|
||||||
public override void Tick (TimeSpan time)
|
public override void Tick (TimeSpan time)
|
||||||
{
|
{
|
||||||
if (paused) return;
|
if (paused)
|
||||||
|
return;
|
||||||
timeStamp += time;
|
timeStamp += time;
|
||||||
lock(this) {
|
if (Monitor.TryEnter (this))
|
||||||
if (enTransition) {
|
try {
|
||||||
if (timeStamp < tempsTransition) {
|
if (enTransition) {
|
||||||
double progression = timeStamp.TotalMilliseconds / tempsTransition.TotalMilliseconds;
|
if (timeStamp < tempsTransition) {
|
||||||
foreach (Circuit c in circuitsSeq) {
|
double progression = timeStamp.TotalMilliseconds / tempsTransition.TotalMilliseconds;
|
||||||
if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) {
|
foreach (Circuit c in circuitsSeq) {
|
||||||
valeurscourantes [c] = (int)(progression * (effetcourrant [c] - valeursinitiales [c]) + valeursinitiales [c]);
|
if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) {
|
||||||
|
valeurscourantes [c] = (int)(progression * (effetcourrant [c] - valeursinitiales [c]) + valeursinitiales [c]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
FinDeTransition ();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
FinDeTransition ();
|
|
||||||
}
|
}
|
||||||
|
if (effetcourrant.Duree != TimeSpan.Zero && timeStamp >= effetcourrant.Duree) {
|
||||||
|
int index = effets.IndexOf (effetcourrant) + 1;
|
||||||
|
if (index < effets.Count)
|
||||||
|
ChangeEffetCourrant (index);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Monitor.Exit (this);
|
||||||
}
|
}
|
||||||
if (effetcourrant.Duree != TimeSpan.Zero && timeStamp >= effetcourrant.Duree) {
|
|
||||||
int index = effets.IndexOf (effetcourrant) + 1;
|
|
||||||
if (index < effets.Count)
|
|
||||||
ChangeEffetCourrant (index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -311,26 +312,28 @@ namespace DMX2
|
||||||
return;
|
return;
|
||||||
timeStamp += time;
|
timeStamp += time;
|
||||||
|
|
||||||
|
if (Monitor.TryEnter (this)) {
|
||||||
|
try {
|
||||||
|
if (effetsEnCours.Count > 0) {
|
||||||
|
List<Circuit> circuits = new List<Circuit> (effetsEnCours.Keys);
|
||||||
|
|
||||||
lock (this) {
|
foreach (Circuit c in circuits) {
|
||||||
if(effetsEnCours.Count>0)
|
if (effetsEnCours [c].Incremente (time)) {
|
||||||
{
|
valeurscourantes [c] = effetsEnCours [c].ValeurFinale;
|
||||||
List<Circuit> circuits = new List<Circuit> (effetsEnCours.Keys);
|
effetsEnCours.Remove (c);
|
||||||
|
} else {
|
||||||
foreach (Circuit c in circuits) {
|
valeurscourantes [c] = effetsEnCours [c].ValeurCourante ();
|
||||||
if (effetsEnCours [c].Incremente (time)) {
|
}
|
||||||
valeurscourantes [c] = effetsEnCours [c].ValeurFinale;
|
|
||||||
effetsEnCours.Remove (c);
|
|
||||||
} else {
|
|
||||||
valeurscourantes [c] = effetsEnCours [c].ValeurCourante ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topPresent) {
|
if (topPresent) {
|
||||||
if (timeStamp > topSuivant){
|
if (timeStamp > topSuivant) {
|
||||||
LigneSuivante();
|
LigneSuivante ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Monitor.Exit (this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue