private void InitDebouncedDownloadLogic() { latestRawSheetData = null; // Create a debounced func that only downloads new data max every 10 seconds and // trigger this method only if inet available: Func <object, Task> debouncedFunc = DowloadOnlineData; debouncedFunc = debouncedFunc.AsThrottledDebounce(delayInMsBetweenCheck); dowloadOnlineDataDebounced = async() => { if (latestRawSheetData.IsNullOrEmpty()) { await InternetStateManager.Instance(this).HasInetAsync; } if (InternetStateManager.Instance(this).HasInet) { try { await debouncedFunc(null); ThrowIfSheetDataMissing(); return(true); } catch (TaskCanceledException) { } // If debouncing decided the task does not need to run } else // No inet, so check if cached data is present: { var fallbackContent = await fallbackStore.GetAllKeys(); if (!fallbackContent.IsNullOrEmpty()) { return(false); } } ThrowIfSheetDataMissing(); return(false); }; }
public async Task TestInternetStateListener20Times() { Assert.False(InternetStateManager.Instance(this).HasInet); for (int i = 0; i < 20; i++) { await TestInternetStateListenerOnce(); } }
public DefaultAppFlowImpl(IKeyValueStore store = null) { this.store = store == null?FileBasedKeyValueStore.New("AppFlowEvents") : store; #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed InternetStateManager.AddListener(this); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
public async Task TestInternetStateListenerOnce() { InternetStateManager.AddListener(this); Assert.True(await RestFactory.instance.HasInternet()); Assert.True(await InternetStateManager.Instance(this).HasInetAsync); Assert.True(InternetStateManager.Instance(this).HasInet); Assert.True(hasInet); InternetStateManager.RemoveListener(this); }
public async Task TestInternetStateListener() { await InternetStateManager.AddListener(this); Assert.False(InternetStateManager.Get(this).hasInet); Assert.False(hasInet); await TaskV2.Delay(2500); Assert.True(hasInet); }
public async Task TestInternetStateListener() { InternetStateManager.AddListener(this); Assert.False(InternetStateManager.Instance(this).HasInet); Assert.False(hasInet); await InternetStateManager.Instance(this).HasInetAsync; Assert.True(InternetStateManager.Instance(this).HasInet); Assert.True(hasInet); }
public static async Task CheckForLatestVersion() { do { await Task.Delay(3000); // Wait at least 3sec before starting } while (!(await InternetStateManager.Instance(null).HasInetAsync)); // Wait until internet awailable var installedPackages = await GetInstalledPackagesFromPackageManager(); await CheckForUpdates(installedPackages, "https://raw.githubusercontent.com/cs-util-com/cscore/master/CsCore/PlainNetClassLib/src/Plugins/package.json"); await CheckForUpdates(installedPackages, "https://raw.githubusercontent.com/cs-util-com/cscore/master/CsCore/CsCoreUnity/Plugins/package.json"); }
public void Dispose() { InternetStateManager.RemoveListener(this); }
public AppUpdateChecker(Action <List <UpdateEntry> > showUserUpdateInstructions) { this.showUserUpdateInstructions = showUserUpdateInstructions; InternetStateManager.AddListener(this); }
public DefaultAppFlowImpl(KeyValueStoreTypeAdapter <AppFlowEvent> store = null) : base(store) { InternetStateManager.AddListener(this); }