mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Correctly test Framework Run vs. RunOnTick
This commit is contained in:
parent
c1805bd510
commit
f812bf8f09
1 changed files with 30 additions and 5 deletions
|
|
@ -3,6 +3,10 @@ using System.Threading.Tasks;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
||||||
|
using Microsoft.VisualBasic.Logging;
|
||||||
|
|
||||||
|
using Log = Serilog.Log;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
|
namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -25,15 +29,29 @@ internal class FrameworkTaskSchedulerSelfTestStep : ISelfTestStep
|
||||||
{
|
{
|
||||||
ThreadSafety.AssertNotMainThread();
|
ThreadSafety.AssertNotMainThread();
|
||||||
|
|
||||||
|
await framework.Run(async () =>
|
||||||
|
{
|
||||||
|
ThreadSafety.AssertMainThread();
|
||||||
|
|
||||||
|
await Task.Delay(100).ConfigureAwait(true);
|
||||||
|
ThreadSafety.AssertMainThread();
|
||||||
|
|
||||||
|
await Task.Delay(100).ConfigureAwait(false);
|
||||||
|
ThreadSafety.AssertNotMainThread();
|
||||||
|
}).ConfigureAwait(true);
|
||||||
|
|
||||||
|
ThreadSafety.AssertNotMainThread();
|
||||||
|
|
||||||
await framework.RunOnTick(async () =>
|
await framework.RunOnTick(async () =>
|
||||||
{
|
{
|
||||||
ThreadSafety.AssertMainThread();
|
ThreadSafety.AssertMainThread();
|
||||||
await Task.Delay(100);
|
|
||||||
|
|
||||||
// TODO: Should we be scheduled back to the framework thread here?
|
await Task.Delay(100).ConfigureAwait(true);
|
||||||
// ThreadSafety.AssertMainThread();
|
|
||||||
ThreadSafety.AssertNotMainThread();
|
ThreadSafety.AssertNotMainThread();
|
||||||
}).ConfigureAwait(false);
|
|
||||||
|
await Task.Delay(100).ConfigureAwait(false);
|
||||||
|
ThreadSafety.AssertNotMainThread();
|
||||||
|
}).ConfigureAwait(true);
|
||||||
|
|
||||||
ThreadSafety.AssertNotMainThread();
|
ThreadSafety.AssertNotMainThread();
|
||||||
|
|
||||||
|
|
@ -45,7 +63,14 @@ internal class FrameworkTaskSchedulerSelfTestStep : ISelfTestStep
|
||||||
ThreadSafety.AssertMainThread();
|
ThreadSafety.AssertMainThread();
|
||||||
|
|
||||||
this.passed = true;
|
this.passed = true;
|
||||||
});
|
}).ContinueWith(
|
||||||
|
t =>
|
||||||
|
{
|
||||||
|
if (t.IsFaulted)
|
||||||
|
{
|
||||||
|
Log.Error(t.Exception, "Framework Task scheduler test failed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.task is { IsFaulted: true } or { IsCanceled: true })
|
if (this.task is { IsFaulted: true } or { IsCanceled: true })
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue