Skip to content

Commit

Permalink
Put back a double cast (int)(uint) which was in fact needed (I guess …
Browse files Browse the repository at this point in the history
…because of P/Invoke calls underneath).

Forced HorizontalAlignement for Auto-refresh button in Connections page (will fix that later in Wokhan.UI).
  • Loading branch information
wokhan committed Oct 29, 2020
1 parent 7d2287a commit ede29ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Common/Processes/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ public static string[] GetProcessOwnerWMI(int owningPid, ref Dictionary<int, str
{
using var searcher = new ManagementObjectSearcher("SELECT ProcessId, Name, ExecutablePath, CommandLine FROM Win32_Process");
using var results = searcher.Get();
previousCache = results.Cast<ManagementObject>().ToDictionary(r => (int)r["ProcessId"], r => new[] { (string)r["Name"], (string)r["ExecutablePath"], (string)r["CommandLine"] });
// Looks like the first cast to uint is required for this to work (pretty weird if you ask me).
previousCache = results.Cast<ManagementObject>().ToDictionary(r => (int)(uint)r["ProcessId"], r => new[] { (string)r["Name"], (string)r["ExecutablePath"], (string)r["CommandLine"] });
}

if (!previousCache.ContainsKey(owningPid))
{
using var searcher = new ManagementObjectSearcher($"SELECT ProcessId, Name, ExecutablePath, CommandLine FROM Win32_Process WHERE ProcessId = {owningPid}");
using var r = searcher.Get().Cast<ManagementObject>().FirstOrDefault();
previousCache.Add((int)r["ProcessId"], new[] { (string)r["Name"], (string)r["ExecutablePath"], (string)r["CommandLine"] });
previousCache.Add(owningPid, new[] { (string)r["Name"], (string)r["ExecutablePath"], (string)r["CommandLine"] });
}

return previousCache[owningPid];
Expand Down
2 changes: 1 addition & 1 deletion Console/UI/Pages/Connections.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<controls:AdminPanel Caption="Information provided here might be inaccurate for non-admin users." />
<ContentControl Style="{StaticResource ToolBarPanel}" Panel.ZIndex="0">
<Grid>
<ToggleButton Content="Auto-refresh" IsChecked="{Binding IsTrackingEnabled}" Style="{StaticResource AutoTrackButton}" />
<ToggleButton HorizontalAlignment="Left" Content="Auto-refresh" IsChecked="{Binding IsTrackingEnabled}" Style="{StaticResource AutoTrackButton}" />
<StackPanel HorizontalAlignment="Right">
<TextBlock VerticalAlignment="Center" Text="{Binding connectionsView.Count, StringFormat='Active connection(s): {0}', FallbackValue='No active connection'}" />
<ComboBox Style="{StaticResource AutoTrackRefresh}" ItemsSource="{Binding Intervals, StringFormat='\{0\}s'}" SelectedValue="{Binding Interval}" />
Expand Down

0 comments on commit ede29ff

Please sign in to comment.