Skip to content

Commit 58e069f

Browse files
committed
- Added improved and faster task loop cancellation code. (WIP4.1)
1 parent afc066d commit 58e069f

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Client/AmbiPro/ModeColorLoop.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Reflection;
33
using System.Threading.Tasks;
44
using static AmbiPro.AppTasks;
5+
using static ArnoldVinkCode.AVActions;
56

67
namespace AmbiPro
78
{
@@ -68,7 +69,7 @@ private static async Task ModeColorLoop(int InitByteSize, byte[] SerialBytes)
6869
vSerialComPort.Write(SerialBytes, 0, SerialBytes.Length);
6970

7071
//Delay the loop task
71-
await Task.Delay(setColorLoopSpeed, vTask_LedUpdate.TokenCancel);
72+
await TaskDelayLoop(setColorLoopSpeed, vTask_LedUpdate);
7273
}
7374
}
7475
catch { }

Client/AmbiPro/ModeColorSpectrum.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Reflection;
66
using System.Threading.Tasks;
77
using static AmbiPro.AppTasks;
8+
using static ArnoldVinkCode.AVActions;
89

910
namespace AmbiPro
1011
{
@@ -107,7 +108,7 @@ private static async Task ModeColorSpectrum(int InitByteSize, byte[] SerialBytes
107108
vSerialComPort.Write(SerialBytes, 0, SerialBytes.Length);
108109

109110
//Delay the loop task
110-
await Task.Delay(1000, vTask_LedUpdate.TokenCancel);
111+
await TaskDelayLoop(1000, vTask_LedUpdate);
111112
}
112113
}
113114
catch { }

Client/AmbiPro/ModeScreenCapture.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Reflection;
55
using System.Threading.Tasks;
66
using static AmbiPro.AppTasks;
7+
using static ArnoldVinkCode.AVActions;
78

89
namespace AmbiPro
910
{
@@ -142,7 +143,7 @@ private static async Task ModeScreenCapture(int InitByteSize, byte[] SerialBytes
142143
AppImport.CaptureFreeMemory(IntPtrBitmap);
143144

144145
//Delay the loop task
145-
await Task.Delay(setUpdateRate, vTask_LedUpdate.TokenCancel);
146+
await TaskDelayLoop(setUpdateRate, vTask_LedUpdate);
146147
}
147148
}
148149
catch { }

Client/AmbiPro/ModeSolidColor.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Reflection;
33
using System.Threading.Tasks;
44
using static AmbiPro.AppTasks;
5+
using static ArnoldVinkCode.AVActions;
56

67
namespace AmbiPro
78
{
@@ -41,7 +42,7 @@ private static async Task ModeSolidColor(int InitByteSize, byte[] SerialBytes)
4142
vSerialComPort.Write(SerialBytes, 0, SerialBytes.Length);
4243

4344
//Delay the loop task
44-
await Task.Delay(1000, vTask_LedUpdate.TokenCancel);
45+
await TaskDelayLoop(1000, vTask_LedUpdate);
4546
}
4647
}
4748
catch { }

0 commit comments

Comments
 (0)