Verrou non bloquant

This commit is contained in:
tzim 2013-11-23 12:05:59 +00:00
parent 9c41df3665
commit b5fc4fda64
2 changed files with 40 additions and 32 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
namespace DMX2
{
@ -321,9 +322,11 @@ namespace DMX2
public override void Tick (TimeSpan time)
{
if (paused) return;
if (paused)
return;
timeStamp += time;
lock(this) {
if (Monitor.TryEnter (this))
try {
if (enTransition) {
if (timeStamp < tempsTransition) {
double progression = timeStamp.TotalMilliseconds / tempsTransition.TotalMilliseconds;
@ -341,6 +344,8 @@ namespace DMX2
if (index < effets.Count)
ChangeEffetCourrant (index);
}
} finally {
Monitor.Exit (this);
}
}

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Xml;
using System.Collections.ObjectModel;
using System.Threading;
namespace DMX2
{
@ -311,10 +312,9 @@ namespace DMX2
return;
timeStamp += time;
lock (this) {
if(effetsEnCours.Count>0)
{
if (Monitor.TryEnter (this)) {
try {
if (effetsEnCours.Count > 0) {
List<Circuit> circuits = new List<Circuit> (effetsEnCours.Keys);
foreach (Circuit c in circuits) {
@ -326,13 +326,16 @@ namespace DMX2
}
}
}
}
if (topPresent) {
if (timeStamp > topSuivant) {
LigneSuivante ();
}
}
} finally {
Monitor.Exit (this);
}
}
}
public void LigneSuivante ()