mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Wait for cursor hiding using ManualResetEventSlim (#6112)
Wait for cursor hiding using ManualResetEventSlim
This commit is contained in:
@ -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())
|
||||||
|
Reference in New Issue
Block a user