Files
ThreadPilot/Helpers/AffinityHelper.cs
T
2026-06-24 17:52:45 +02:00

26 lines
812 B
C#

namespace ThreadPilot.Helpers
{
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
public static class AffinityHelper
{
public static long CalculateAffinityMask(IEnumerable<System.Windows.Controls.CheckBox> cpuCheckboxes)
{
return cpuCheckboxes
.Where(cb => cb.IsChecked == true)
.Sum(cb => (long)cb.Tag);
}
public static void UpdateCheckboxesFromMask(IEnumerable<System.Windows.Controls.CheckBox> cpuCheckboxes, long affinityMask)
{
foreach (var checkbox in cpuCheckboxes)
{
var cpuBit = (long)checkbox.Tag;
checkbox.IsChecked = (affinityMask & cpuBit) != 0;
}
}
}
}