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:
parent
f24e1ae264
commit
ec69db7201
@ -4,7 +4,6 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Ninject;
|
|
||||||
|
|
||||||
namespace Artemis.Core.Modules
|
namespace Artemis.Core.Modules
|
||||||
{
|
{
|
||||||
@ -13,8 +12,6 @@ namespace Artemis.Core.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessActivationRequirement : IModuleActivationRequirement
|
public class ProcessActivationRequirement : IModuleActivationRequirement
|
||||||
{
|
{
|
||||||
private readonly IProcessMonitorService _processMonitorService;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="ProcessActivationRequirement" /> class
|
/// Creates a new instance of the <see cref="ProcessActivationRequirement" /> class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -25,11 +22,6 @@ namespace Artemis.Core.Modules
|
|||||||
if (string.IsNullOrWhiteSpace(processName) && string.IsNullOrWhiteSpace(location))
|
if (string.IsNullOrWhiteSpace(processName) && string.IsNullOrWhiteSpace(location))
|
||||||
throw new ArgumentNullException($"Atleast one {nameof(processName)} and {nameof(location)} must not be null");
|
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;
|
ProcessName = processName;
|
||||||
Location = location;
|
Location = location;
|
||||||
}
|
}
|
||||||
@ -44,13 +36,15 @@ namespace Artemis.Core.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Location { get; set; }
|
public string? Location { get; set; }
|
||||||
|
|
||||||
|
internal static IProcessMonitorService? ProcessMonitorService { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Evaluate()
|
public bool Evaluate()
|
||||||
{
|
{
|
||||||
if (ProcessName == null && Location == null)
|
if (ProcessMonitorService == null || ProcessName == null && Location == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IEnumerable<Process> processes = _processMonitorService.GetRunningProcesses();
|
IEnumerable<Process> processes = ProcessMonitorService.GetRunningProcesses();
|
||||||
if (ProcessName != null)
|
if (ProcessName != null)
|
||||||
processes = processes.Where(p => string.Equals(p.ProcessName, ProcessName, StringComparison.InvariantCultureIgnoreCase));
|
processes = processes.Where(p => string.Equals(p.ProcessName, ProcessName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
if (Location != null)
|
if (Location != null)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using Artemis.Core.Modules;
|
||||||
|
|
||||||
namespace Artemis.Core.Services
|
namespace Artemis.Core.Services
|
||||||
{
|
{
|
||||||
@ -22,6 +23,8 @@ namespace Artemis.Core.Services
|
|||||||
_processScanTimer.Elapsed += OnTimerElapsed;
|
_processScanTimer.Elapsed += OnTimerElapsed;
|
||||||
_processScanTimer.Start();
|
_processScanTimer.Start();
|
||||||
_comparer = new ProcessComparer();
|
_comparer = new ProcessComparer();
|
||||||
|
|
||||||
|
ProcessActivationRequirement.ProcessMonitorService = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler<ProcessEventArgs>? ProcessStarted;
|
public event EventHandler<ProcessEventArgs>? ProcessStarted;
|
||||||
@ -67,4 +70,4 @@ namespace Artemis.Core.Services
|
|||||||
return obj.Id;
|
return obj.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,10 +44,10 @@
|
|||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
OpacityMask="{x:Null}">
|
OpacityMask="{x:Null}">
|
||||||
<Track.DecreaseRepeatButton>
|
<Track.DecreaseRepeatButton>
|
||||||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{DynamicResource MaterialDesignHorizontalColorSliderTrackRepeatButton}" />
|
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource MaterialDesignRepeatButton}" />
|
||||||
</Track.DecreaseRepeatButton>
|
</Track.DecreaseRepeatButton>
|
||||||
<Track.IncreaseRepeatButton>
|
<Track.IncreaseRepeatButton>
|
||||||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{DynamicResource MaterialDesignHorizontalColorSliderTrackRepeatButton}" />
|
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource MaterialDesignRepeatButton}" />
|
||||||
</Track.IncreaseRepeatButton>
|
</Track.IncreaseRepeatButton>
|
||||||
<Track.Thumb>
|
<Track.Thumb>
|
||||||
<Thumb x:Name="Thumb" Width="20" Height="20" VerticalAlignment="Center" Focusable="False" OverridesDefaultStyle="True"
|
<Thumb x:Name="Thumb" Width="20" Height="20" VerticalAlignment="Center" Focusable="False" OverridesDefaultStyle="True"
|
||||||
|
|||||||
@ -372,6 +372,7 @@
|
|||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Panel.ZIndex="2"
|
Panel.ZIndex="2"
|
||||||
|
ClipToBounds="False"
|
||||||
Background="{DynamicResource MaterialDesignCardBackground}">
|
Background="{DynamicResource MaterialDesignCardBackground}">
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -433,12 +434,11 @@
|
|||||||
<Slider Grid.Column="1"
|
<Slider Grid.Column="1"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Margin="10 5"
|
VerticalAlignment="Center"
|
||||||
|
materialDesign:SliderAssist.OnlyShowFocusVisualWhileDragging="True"
|
||||||
Minimum="31"
|
Minimum="31"
|
||||||
Maximum="350"
|
Maximum="350"
|
||||||
TickFrequency="1"
|
Margin="10 0"
|
||||||
IsSnapToTickEnabled="True"
|
|
||||||
AutoToolTipPlacement="TopLeft"
|
|
||||||
Value="{Binding ProfileEditorService.PixelsPerSecond}"
|
Value="{Binding ProfileEditorService.PixelsPerSecond}"
|
||||||
Foreground="{StaticResource SecondaryHueMidBrush}"
|
Foreground="{StaticResource SecondaryHueMidBrush}"
|
||||||
Width="319" />
|
Width="319" />
|
||||||
|
|||||||
@ -224,6 +224,4 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
Loading…
x
Reference in New Issue
Block a user