mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Wait for cursor hiding using ManualResetEventSlim
This commit is contained in:
parent
bc2a1c91a1
commit
8456861b8d
@ -83,11 +83,19 @@ namespace osu.Game.Graphics
|
|||||||
const int frames_to_wait = 3;
|
const int frames_to_wait = 3;
|
||||||
|
|
||||||
int framesWaited = 0;
|
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())
|
using (var image = await host.TakeScreenshotAsync())
|
||||||
|
Loading…
Reference in New Issue
Block a user