1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Process activation requirement - Fixed deadlock on shutdown

This commit is contained in:
Robert 2021-06-19 14:53:48 +02:00
parent f24e1ae264
commit ec69db7201
5 changed files with 14 additions and 19 deletions

View File

@ -4,7 +4,6 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using Artemis.Core.Services;
using Ninject;
namespace Artemis.Core.Modules
{
@ -13,8 +12,6 @@ namespace Artemis.Core.Modules
/// </summary>
public class ProcessActivationRequirement : IModuleActivationRequirement
{
private readonly IProcessMonitorService _processMonitorService;
/// <summary>
/// Creates a new instance of the <see cref="ProcessActivationRequirement" /> class
/// </summary>
@ -25,11 +22,6 @@ namespace Artemis.Core.Modules
if (string.IsNullOrWhiteSpace(processName) && string.IsNullOrWhiteSpace(location))
throw new ArgumentNullException($"Atleast one {nameof(processName)} and {nameof(location)} must not be null");
// Let's not make a habit out of this :P
if (CoreService.Kernel == null)
throw new ArtemisCoreException("Cannot create a ProcessActivationRequirement before initializing the Core");
_processMonitorService = CoreService.Kernel.Get<IProcessMonitorService>();
ProcessName = processName;
Location = location;
}
@ -44,13 +36,15 @@ namespace Artemis.Core.Modules
/// </summary>
public string? Location { get; set; }
internal static IProcessMonitorService? ProcessMonitorService { get; set; }
/// <inheritdoc />
public bool Evaluate()
{
if (ProcessName == null && Location == null)
if (ProcessMonitorService == null || ProcessName == null && Location == null)
return false;
IEnumerable<Process> processes = _processMonitorService.GetRunningProcesses();
IEnumerable<Process> processes = ProcessMonitorService.GetRunningProcesses();
if (ProcessName != null)
processes = processes.Where(p => string.Equals(p.ProcessName, ProcessName, StringComparison.InvariantCultureIgnoreCase));
if (Location != null)

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Timers;
using Artemis.Core.Modules;
namespace Artemis.Core.Services
{
@ -22,6 +23,8 @@ namespace Artemis.Core.Services
_processScanTimer.Elapsed += OnTimerElapsed;
_processScanTimer.Start();
_comparer = new ProcessComparer();
ProcessActivationRequirement.ProcessMonitorService = this;
}
public event EventHandler<ProcessEventArgs>? ProcessStarted;
@ -67,4 +70,4 @@ namespace Artemis.Core.Services
return obj.Id;
}
}
}
}

View File

@ -44,10 +44,10 @@
Grid.Row="1"
OpacityMask="{x:Null}">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{DynamicResource MaterialDesignHorizontalColorSliderTrackRepeatButton}" />
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource MaterialDesignRepeatButton}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{DynamicResource MaterialDesignHorizontalColorSliderTrackRepeatButton}" />
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource MaterialDesignRepeatButton}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb x:Name="Thumb" Width="20" Height="20" VerticalAlignment="Center" Focusable="False" OverridesDefaultStyle="True"

View File

@ -372,6 +372,7 @@
Grid.Column="2"
HorizontalAlignment="Stretch"
Panel.ZIndex="2"
ClipToBounds="False"
Background="{DynamicResource MaterialDesignCardBackground}">
<Grid.ColumnDefinitions>
@ -433,12 +434,11 @@
<Slider Grid.Column="1"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="10 5"
VerticalAlignment="Center"
materialDesign:SliderAssist.OnlyShowFocusVisualWhileDragging="True"
Minimum="31"
Maximum="350"
TickFrequency="1"
IsSnapToTickEnabled="True"
AutoToolTipPlacement="TopLeft"
Margin="10 0"
Value="{Binding ProfileEditorService.PixelsPerSecond}"
Foreground="{StaticResource SecondaryHueMidBrush}"
Width="319" />

View File

@ -224,6 +224,4 @@
</Grid>
</Grid>
</Grid>
</UserControl>