1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 07:13:58 -05:00

harden up the script timer/game interface dvar operations for multithreading

This commit is contained in:
RaidMax
2022-10-23 14:03:33 -05:00
parent 5b7e56f894
commit 7b2cd19fc1
5 changed files with 95 additions and 48 deletions

View File

@ -409,24 +409,9 @@ namespace SharedLibraryCore
public abstract Task<long> GetIdForServer(Server server = null);
public string[] ExecuteServerCommand(string command, int timeoutMs = 1000)
{
var tokenSource = new CancellationTokenSource();
tokenSource.CancelAfter(TimeSpan.FromSeconds(timeoutMs));
try
{
return this.ExecuteCommandAsync(command, tokenSource.Token).GetAwaiter().GetResult();
}
catch
{
return null;
}
}
public string GetServerDvar(string dvarName, int timeoutMs = 1000)
{
var tokenSource = new CancellationTokenSource();
using var tokenSource = new CancellationTokenSource();
tokenSource.CancelAfter(TimeSpan.FromSeconds(timeoutMs));
try
{
@ -440,7 +425,7 @@ namespace SharedLibraryCore
public bool SetServerDvar(string dvarName, string dvarValue, int timeoutMs = 1000)
{
var tokenSource = new CancellationTokenSource();
using var tokenSource = new CancellationTokenSource();
tokenSource.CancelAfter(TimeSpan.FromSeconds(timeoutMs));
try
{