private async Task UpdateImplAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name); } catch (RHostDisconnectedException) { AddErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_CantUnloadPackageNoRSession, package.Name)); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadLoadedPackagesAsync(); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); try { var packageLockState = await _packageManager.UpdatePackageAsync(package.Name, libPath); if (packageLockState != PackageLockState.Unlocked) { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RHostDisconnectedException) { AddErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_CantUpdatePackageNoRSession, package.Name)); } } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } } await ReloadInstalledAndLoadedPackagesAsync(); }