Skip to content

Commit

Permalink
Replace sleep with task.await - smoother performance and less CPU usage
Browse files Browse the repository at this point in the history
  • Loading branch information
winglessraven committed Sep 13, 2020
1 parent 0474e41 commit 940e52a
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 11 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.5.0")]
[assembly: AssemblyFileVersion("1.8.5.0")]
[assembly: AssemblyVersion("1.8.6.0")]
[assembly: AssemblyFileVersion("1.8.6.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,11 @@ private void saveConfig_Click(object sender, EventArgs e)
{
if (dataGridViewRow.Cells[3].Value.ToString().Equals("Engine.ini"))
{
if (writeConfigs.Exists(p => p.Script == dataGridViewRow.Cells[2].Value))
if (writeConfigs.Exists(p => p.Script.Equals(dataGridViewRow.Cells[2].Value)))
{
if (dataGridViewRow.Cells[1].Value != null)
{
writeConfigs.Find(p => p.Script == dataGridViewRow.Cells[2].Value).Values += Environment.NewLine + dataGridViewRow.Cells[0].Value.ToString() + "=" + dataGridViewRow.Cells[1].Value.ToString();
writeConfigs.Find(p => p.Script.Equals(dataGridViewRow.Cells[2].Value)).Values += Environment.NewLine + dataGridViewRow.Cells[0].Value.ToString() + "=" + dataGridViewRow.Cells[1].Value.ToString();
}
}
else
Expand Down Expand Up @@ -818,7 +818,7 @@ private void startServer_Click(object sender, EventArgs e)
private async void MonitorServer(string maxMemory)
{
SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

await Task.Delay(500);
await Task.Run(() =>
{
long memory;
Expand Down Expand Up @@ -1042,9 +1042,14 @@ await Task.Run(() =>
}
});

Thread.Sleep(30);
await Monitor(maxServerMemory.Text);

MonitorServer(maxServerMemory.Text);
}

public Task Monitor(string maxMemory)
{
MonitorServer(maxMemory);
return Task.CompletedTask;
}

public string ReadControl(Control control)
Expand Down Expand Up @@ -1879,7 +1884,7 @@ private async void SendDiscordWebHook(string message,Color colour)
await client.SendToDiscord(messageTxt);

}
catch(Exception ex)
catch
{
//fail!!
}
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ C:\Users\Dave\Source\Repos\DeadMatterServerManager\Dead Matter Server Manager\De
C:\Users\Dave\Source\Repos\DeadMatterServerManager\Dead Matter Server Manager\Dead Matter Server Manager\bin\x64\Debug\Polly.pdb
C:\Users\Dave\Source\Repos\DeadMatterServerManager\Dead Matter Server Manager\Dead Matter Server Manager\bin\x64\Debug\Polly.xml
C:\Users\Dave\Source\Repos\DeadMatterServerManager\Dead Matter Server Manager\Dead Matter Server Manager\bin\x64\Debug\System.Net.Http.Formatting.xml
C:\Users\Dave\Source\Repos\DeadMatterServerManager\Dead Matter Server Manager\Dead Matter Server Manager\obj\x64\Debug\Dead Matter Server Manager.csprojAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6452,15 +6452,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Dead Matter Server Manager"
"ProductCode" = "8:{B4E838C7-8B9B-47FC-9060-05481602D908}"
"PackageCode" = "8:{D5AACA30-4DFE-41E0-9005-E9B80AF24587}"
"ProductCode" = "8:{F54979A5-89E1-4F58-9CB8-80BF6E119A00}"
"PackageCode" = "8:{AF3589F6-D360-4289-A286-FEBD36832BFD}"
"UpgradeCode" = "8:{BC345328-E944-4F2F-9559-E95043070B11}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.8.5"
"ProductVersion" = "8:1.8.6"
"Manufacturer" = "8:winglessraven"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down
Binary file not shown.

0 comments on commit 940e52a

Please sign in to comment.