Ejemplo n.º 1
0
        /// <exception cref="LockFileNotAcquiredException"></exception>
        /// <exception cref="UpdaterAlreadyLaunchedException "></exception>
        public async Task <bool> FetchUpdateAsync()
        {
            using var manager = new Onova.UpdateManager(PackageResolver, new ZipPackageExtractor());

            UpdatesResult = await manager.CheckForUpdatesAsync();

            return(UpdatesResult.CanUpdate);
        }
Ejemplo n.º 2
0
        /// <exception cref="Onova.Exceptions.LockFileNotAcquiredException"></exception>
        /// <exception cref="Onova.Exceptions.UpdaterAlreadyLaunchedException"></exception>
        /// <exception cref="InvalidOperationException"></exception>
        public async Task StartUpdateAsync()
        {
            if (UpdatesResult == null)
            {
                throw new InvalidOperationException("Do not call this method before fetching updates!");
            }

            if (!UpdatesResult.CanUpdate)
            {
                throw new InvalidOperationException("Do not call this method if there are no updates!");
            }

            using var manager = new Onova.UpdateManager(PackageResolver, new ZipPackageExtractor());

            await manager.PrepareUpdateAsync(UpdatesResult.LastVersion, Progress);

            IsReadyToUpdate?.Invoke(this, null);

            Lock.WaitOne();

            manager.LaunchUpdater(UpdatesResult.LastVersion, RestartAfterUpdate);
        }