Skip to content

Commit eb15622

Browse files
committed
fixed possible null exceptions on some devices
1 parent a27de13 commit eb15622

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Project-Aurora/Project-Aurora/Devices/DeviceManager.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ public class DeviceContainer
2323
private Tuple<DeviceColorComposition, bool> currentComp;
2424

2525
public readonly object actionLock = new object();
26+
private readonly Action _updateAction;
2627

2728
public DeviceContainer(IDevice device)
2829
{
29-
this.Device = device;
30+
Device = device;
31+
var args = new DoWorkEventArgs(null);
32+
_updateAction = () =>
33+
{
34+
WorkerOnDoWork(this, args);
35+
};
3036
}
3137

3238
private void WorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
@@ -37,16 +43,12 @@ private void WorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
3743
currentComp.Item2);
3844
}
3945
}
40-
4146
public void UpdateDevice(DeviceColorComposition composition, bool forced = false)
4247
{
4348
currentComp = new Tuple<DeviceColorComposition, bool>(composition, forced);
4449
if (Worker.WaitingCallbacks < 1)
4550
{
46-
Worker.QueueWorkItem((() =>
47-
{
48-
WorkerOnDoWork(null, null);
49-
}));
51+
Worker.QueueWorkItem(_updateAction);
5052
}
5153
}
5254
}

0 commit comments

Comments
 (0)