diff --git a/osu.Game/Screens/OnlinePlay/OngoingOperationTracker.cs b/osu.Game/Screens/OnlinePlay/OngoingOperationTracker.cs
index f2d943e14f..6a340d7954 100644
--- a/osu.Game/Screens/OnlinePlay/OngoingOperationTracker.cs
+++ b/osu.Game/Screens/OnlinePlay/OngoingOperationTracker.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using osu.Framework.Allocation;
using osu.Framework.Bindables;
namespace osu.Game.Screens.OnlinePlay
@@ -24,21 +25,26 @@ namespace osu.Game.Screens.OnlinePlay
///
/// Begins tracking a new online operation.
///
+ ///
+ /// An that will automatically mark the operation as ended on disposal.
+ ///
/// An operation has already been started.
- public void BeginOperation()
+ public IDisposable BeginOperation()
{
if (leasedInProgress != null)
throw new InvalidOperationException("Cannot begin operation while another is in progress.");
leasedInProgress = inProgress.BeginLease(true);
leasedInProgress.Value = true;
+
+ return new InvokeOnDisposal(endOperation);
}
///
/// Ends tracking an online operation.
/// Does nothing if an operation has not been begun yet.
///
- public void EndOperation()
+ private void endOperation()
{
leasedInProgress?.Return();
leasedInProgress = null;