/// <summary> /// Unloads profile after a period of time /// </summary> /// <param name="userId"></param> /// <param name="delay"></param> /// <returns></returns> private async Task UnloadProfile(string userId, float delay) { // Wait for the delay await Task.Delay(Mathf.RoundToInt(delay < 0.01f ? 0.01f * 1000 : delay * 1000)); // If user is logged in, do nothing if (authModule.IsUserLoggedInById(userId)) { return; } profilesList.TryGetValue(userId, out ObservableServerProfile profile); if (profile == null) { return; } // Remove profile profilesList.Remove(userId); // Remove listeners profile.OnModifiedInServerEvent -= OnProfileChangedEventHandler; }