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

Wait for cursor hiding using ManualResetEventSlim (#6112)

Wait for cursor hiding using ManualResetEventSlim
This commit is contained in:
Dean Herbert 2019-09-15 15:00:38 +09:00 committed by GitHub
commit fedbac74e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,11 +83,19 @@ 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);
waitDelegate.Cancel();
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())