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:
commit
fedbac74e4
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user