/// <summary> /// Event handler for finishing requesting changes. /// </summary> void OnFinishedRequestChanges() { if (!m_IsRequestingChanges) { return; } m_IsRequestingChanges = false; BusyStatusUpdated?.Invoke(false); }
/// <summary> /// Event handler for starting to request changes. /// </summary> void OnStartedRequestingChanges() { if (m_IsRequestingChanges) { return; } m_IsRequestingChanges = true; BusyStatusUpdated?.Invoke(true); }
/// <summary> /// Remove a finished request. /// </summary> /// <param name="requestId">Id of the request to remove.</param> void RemoveRequest(string requestId) { Assert.IsTrue(m_Requests.Contains(requestId), $"Expects request to have first been made for it to have been finished: {requestId}"); m_Requests.Remove(requestId); // Signal no background activity if no requests in progress if (m_Requests.Count == 0) { BusyStatusUpdated?.Invoke(false); } }
/// <summary> /// Add a started request. /// </summary> /// <param name="requestId">Id of the request to add.</param> /// <returns>False if the request already exists.</returns> bool AddRequest(string requestId) { if (m_Requests.Contains(requestId)) { return(false); } m_Requests.Add(requestId); // Signal background activity if this is the only thing running. if (m_Requests.Count == 1) { BusyStatusUpdated?.Invoke(true); } return(true); }