get rid of keen threading cringe
All checks were successful
Build / Build Launcher (push) Successful in 2m39s
All checks were successful
Build / Build Launcher (push) Successful in 2m39s
This commit is contained in:
@@ -16,7 +16,6 @@ using VRage.Input;
|
|||||||
using VRage.Utils;
|
using VRage.Utils;
|
||||||
using VRageMath;
|
using VRageMath;
|
||||||
using static Sandbox.Graphics.GUI.MyGuiScreenMessageBox;
|
using static Sandbox.Graphics.GUI.MyGuiScreenMessageBox;
|
||||||
using Parallel = ParallelTasks.Parallel;
|
|
||||||
|
|
||||||
namespace PluginLoader.GUI;
|
namespace PluginLoader.GUI;
|
||||||
|
|
||||||
@@ -122,13 +121,12 @@ public class MyGuiScreenPluginConfig : MyGuiScreenBase
|
|||||||
|
|
||||||
private void DownloadStats()
|
private void DownloadStats()
|
||||||
{
|
{
|
||||||
LogFile.Log.Debug("Downloading user statistics", false);
|
LogFile.Log.Debug("Downloading user statistics");
|
||||||
Parallel.Start(() => { PluginStats = StatsClient.DownloadStats(); }, OnDownloadedStats);
|
Task.Run(() =>
|
||||||
}
|
{
|
||||||
|
StatsClient.DownloadStats();
|
||||||
private void OnDownloadedStats()
|
pluginDetails?.LoadPluginData();
|
||||||
{
|
});
|
||||||
pluginDetails?.LoadPluginData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -6,7 +6,6 @@ using Steamworks;
|
|||||||
using VRage.Game;
|
using VRage.Game;
|
||||||
using VRage.GameServices;
|
using VRage.GameServices;
|
||||||
using VRage.Utils;
|
using VRage.Utils;
|
||||||
using Parallel = ParallelTasks.Parallel;
|
|
||||||
|
|
||||||
namespace PluginLoader;
|
namespace PluginLoader;
|
||||||
|
|
||||||
@@ -38,28 +37,22 @@ public static class SteamAPI
|
|||||||
|
|
||||||
// Source: MyWorkshop.DownloadWorldModsBlocking
|
// Source: MyWorkshop.DownloadWorldModsBlocking
|
||||||
var result = new MyWorkshop.ResultData();
|
var result = new MyWorkshop.ResultData();
|
||||||
var task = Parallel.Start(delegate { result = UpdateInternal(modItems); });
|
var task = Task.Run(() => result = UpdateInternal(modItems));
|
||||||
while (!task.IsComplete)
|
while (!task.IsCompleted)
|
||||||
{
|
{
|
||||||
MyGameService.Update();
|
MyGameService.Update();
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.Result is not MyGameServiceCallResult.OK)
|
if (result.Result is MyGameServiceCallResult.OK) return;
|
||||||
|
|
||||||
|
if (task.Exception is not null)
|
||||||
{
|
{
|
||||||
var exceptions = task.Exceptions;
|
LogFile.Log.Error(task.Exception, "An error occurred while updating workshop items");
|
||||||
if (exceptions is { Length: > 0 })
|
}
|
||||||
{
|
else
|
||||||
var sb = new StringBuilder();
|
{
|
||||||
sb.AppendLine("An error occurred while updating workshop items:");
|
LogFile.Log.Error("Unable to update workshop items due to {Result}", result.Result);
|
||||||
foreach (var e in exceptions)
|
|
||||||
sb.Append(e);
|
|
||||||
LogFile.Log.Debug(sb.ToString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogFile.Log.Debug("Unable to update workshop items");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user