private async Task <bool> RefreshData(LoadDataType loadDataType) { bool success = false; switch (loadDataType) { case LoadDataType.FullData: _viewModel.AllMatchesWithDetails.ToList().ForEach(x => x.IsDataLoaded = false); var refrRefreshSelectedMatchDataTask = RefreshSelectedMatchData(); var refreshFullDataTask = RefreshFullData(); bool[] result = await Task.WhenAll(refrRefreshSelectedMatchDataTask, refreshFullDataTask); success = result.All(x => x == true); break; case LoadDataType.MainData: success = await RefreshFullData(); break; case LoadDataType.MatchDataOnly: success = await RefreshSelectedMatchData(); break; } return(success); }
public async Task ReloadAsync(LoadDataType loadDataType) { await Task.Delay(300); if (_isBusy && loadDataType == LoadDataType.FullData) { return; } _isBusy = true; _viewModel.IsDisconnected = true; bool connected = false; var refreshDataTask = RefreshData(loadDataType); //var tryHubConnectTask = TryHubConnectAsync(); bool[] result = await Task.WhenAll(refreshDataTask /*, tryHubConnectTask*/); connected = result.All(x => x == true); _viewModel.IsDisconnected = !connected; _viewModel.IsConnectionError = !connected && _viewModel.IsApplicationActive; _isBusy = false; if (!connected) { await ReloadAsync(LoadDataType.FullData); } }
public TextAsset LoadTextAssetForAsyn(string bundleName, string assetName, LoadDataType load = LoadDataType.AssetBundleType) { TextAsset textFile = null; if (load == LoadDataType.ResourcesType) { string path = bundleName; if (path.Contains(ABPathHelper.ResourcePrefix)) { path = path.Remove(0, 10); } path += assetName; textFile = Resources.Load(path) as TextAsset; } #if UNITY_EDITOR else if (load == LoadDataType.LoadAssetAtPath) { if (!bundleName.StartsWith("Assets/ABResources/")) { bundleName = "Assets/ABResources/" + bundleName + "/" + assetName + ABPathHelper.AssetXmlSuffix; } else { bundleName = bundleName + "/" + assetName + ABPathHelper.AssetXmlSuffix; } textFile = UnityEditor.AssetDatabase.LoadAssetAtPath <TextAsset>(bundleName); } #endif else { textFile = (TextAsset)ResourceManager.Instance.Loadobject(bundleName, assetName); } return(textFile); }