Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Commit 74af76a

Browse files
Fix Actions freeze when SmartKey is used (#1643)
1 parent c9711c5 commit 74af76a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

LenovoLegionToolkit.Lib.Automation/AutomationProcessor.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@ public async Task RunNowAsync(AutomationPipeline pipeline)
123123
if (Log.Instance.IsTraceEnabled)
124124
Log.Instance.Trace($"Pipeline run now pending...");
125125

126-
List<AutomationPipeline> pipelines;
127-
using (await _ioLock.LockAsync().ConfigureAwait(false))
128-
pipelines = _pipelines.ToList();
129-
130126
using (await _runLock.LockAsync().ConfigureAwait(false))
131127
{
132128
if (Log.Instance.IsTraceEnabled)
133129
Log.Instance.Trace($"Pipeline run starting...");
134130

135131
try
136132
{
133+
List<AutomationPipeline> pipelines;
134+
using (await _ioLock.LockAsync().ConfigureAwait(false))
135+
pipelines = _pipelines.ToList();
136+
137137
var otherPipelines = pipelines.Where(p => p.Id != pipeline.Id).ToList();
138138
await pipeline.DeepCopy().RunAsync(otherPipelines).ConfigureAwait(false);
139139

@@ -152,14 +152,14 @@ public async Task RunNowAsync(AutomationPipeline pipeline)
152152

153153
public async Task RunNowAsync(Guid pipelineId)
154154
{
155-
using (await _runLock.LockAsync().ConfigureAwait(false))
156-
{
157-
var pipeline = _pipelines.Where(p => p.Trigger is null).FirstOrDefault(p => p.Id == pipelineId);
158-
if (pipeline is null)
159-
return;
155+
AutomationPipeline? pipeline;
156+
using (await _ioLock.LockAsync().ConfigureAwait(false))
157+
pipeline = _pipelines.Where(p => p.Trigger is null).FirstOrDefault(p => p.Id == pipelineId);
160158

161-
await RunNowAsync(pipeline).ConfigureAwait(false);
162-
}
159+
if (pipeline is null)
160+
return;
161+
162+
await RunNowAsync(pipeline).ConfigureAwait(false);
163163
}
164164

165165
private async Task RunAsync(IAutomationEvent automationEvent)

LenovoLegionToolkit.WPF/Utils/SmartKeyHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ private async Task ProcessSpecialKey(bool isDoublePress)
106106

107107
try
108108
{
109-
var pipeline = (await _automationProcessor.GetPipelinesAsync()).FirstOrDefault(p => p.Id == currentGuid);
109+
var pipelines = await _automationProcessor.GetPipelinesAsync();
110+
var pipeline = pipelines.FirstOrDefault(p => p.Id == currentGuid);
110111
if (pipeline is not null)
111112
{
112113
if (Log.Instance.IsTraceEnabled)

0 commit comments

Comments
 (0)