Skip to content

Commit

Permalink
Merge pull request #24 from AkarinVS/slow-wmiutils
Browse files Browse the repository at this point in the history
MainWindow.xaml.cs: call WmiUtils.GetAvailablePhysicalMemory() only once
  • Loading branch information
LittlePox authored May 4, 2021
2 parents 806337b + cf5deda commit 7ba401d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions OKEGui/OKEGui/Gui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ private void BtnNew_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(TxtFreeMemory.Text))
{
if (WmiUtils.GetAvailablePhysicalMemory() < 0)
int availMB = WmiUtils.GetAvailablePhysicalMemory();
if (availMB < 0)
{
MessageBox.Show("无法获取当前空闲内存!请自行检查当前可用内存。", "OKEGui", MessageBoxButton.OK, MessageBoxImage.Error);
}
else if (int.Parse(TxtFreeMemory.Text) < WmiUtils.GetAvailablePhysicalMemory())
else if (int.Parse(TxtFreeMemory.Text) < availMB)
{
Initializer.Config.memoryTotal = WmiUtils.GetTotalPhysicalMemory();
}
Expand Down

0 comments on commit 7ba401d

Please sign in to comment.