public async void installUpdate(JObject updatePackage, InstallMode installMode, int minimumBackgroundDuration, IPromise promise) { await _codePush.UpdateManager.InstallPackageAsync(updatePackage, SettingsManager.IsPendingUpdate(null)).ConfigureAwait(false); var pendingHash = (string)updatePackage[CodePushConstants.PackageHashKey]; SettingsManager.SavePendingUpdate(pendingHash, /* isLoading */ false); if (installMode == InstallMode.OnNextResume) { if (_minimumBackgroundListener == null) { // Ensure we do not add the listener twice. Action loadBundleAction = () => { Context.RunOnNativeModulesQueueThread(async() => { await LoadBundleAsync().ConfigureAwait(false); }); }; _minimumBackgroundListener = new MinimumBackgroundListener(loadBundleAction, minimumBackgroundDuration); _reactContext.AddLifecycleEventListener(_minimumBackgroundListener); } else { _minimumBackgroundListener.MinimumBackgroundDuration = minimumBackgroundDuration; } } promise.Resolve(""); }
public void installUpdate(JObject updatePackage, InstallMode installMode, int minimumBackgroundDuration, IPromise promise) { Action installUpdateAction = async () => { await _codePush.UpdateManager.InstallPackage(updatePackage, SettingsManager.IsPendingUpdate(null)); var pendingHash = (string)updatePackage[CodePushConstants.PackageHashKey]; SettingsManager.SavePendingUpdate(pendingHash, /* isLoading */false); if (installMode == InstallMode.OnNextResume) { if (_minimumBackgroundListener == null) { // Ensure we do not add the listener twice. Action loadBundleAction = () => { Context.RunOnNativeModulesQueueThread(async () => { await LoadBundle(); }); }; _minimumBackgroundListener = new MinimumBackgroundListener(loadBundleAction, minimumBackgroundDuration); _reactContext.AddLifecycleEventListener(_minimumBackgroundListener); } else { _minimumBackgroundListener.MinimumBackgroundDuration = minimumBackgroundDuration; } } promise.Resolve(""); }; Context.RunOnNativeModulesQueueThread(installUpdateAction); }