1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Wait for cursor hiding using ManualResetEventSlim

This commit is contained in:
Roman Kapustin 2019-09-14 17:08:56 +03:00
parent bc2a1c91a1
commit 8456861b8d

View File

@ -83,12 +83,20 @@ namespace osu.Game.Graphics
const int frames_to_wait = 3;
int framesWaited = 0;
ScheduledDelegate waitDelegate = host.DrawThread.Scheduler.AddDelayed(() => framesWaited++, 0, true);
while (framesWaited < frames_to_wait)
Thread.Sleep(10);
using (var framesWaitedEvent = new ManualResetEventSlim(false))
{
ScheduledDelegate waitDelegate = host.DrawThread.Scheduler.AddDelayed(() =>
{
if (framesWaited++ < frames_to_wait)
// ReSharper disable once AccessToDisposedClosure
framesWaitedEvent.Set();
}, 10, true);
framesWaitedEvent.Wait();
waitDelegate.Cancel();
}
}
using (var image = await host.TakeScreenshotAsync())
{