mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 15:33:05 +08:00
Don't timeout on long beatmap load when debugging
This commit is contained in:
parent
7072207c7c
commit
916d8245e6
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -84,7 +85,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null, TimeSpan? timeout = null)
|
||||
{
|
||||
using (var cancellationSource = new CancellationTokenSource(timeout ?? TimeSpan.FromSeconds(10)))
|
||||
using (var cancellationSource = createCancellationTokenSource(timeout))
|
||||
{
|
||||
mods ??= Array.Empty<Mod>();
|
||||
|
||||
@ -181,6 +182,15 @@ namespace osu.Game.Beatmaps
|
||||
beatmapLoadTask = null;
|
||||
}
|
||||
|
||||
private CancellationTokenSource createCancellationTokenSource(TimeSpan? timeout)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
// ignore timeout when debugger is attached (may be breakpointing / debugging).
|
||||
return new CancellationTokenSource();
|
||||
|
||||
return new CancellationTokenSource(timeout ?? TimeSpan.FromSeconds(10));
|
||||
}
|
||||
|
||||
private Task<IBeatmap> loadBeatmapAsync() => beatmapLoadTask ??= Task.Factory.StartNew(() =>
|
||||
{
|
||||
// Todo: Handle cancellation during beatmap parsing
|
||||
|
Loading…
Reference in New Issue
Block a user