Example #1
0
        private Task <int> RunProcessAsync(Process process)
        {
            var tcs = new TaskCompletionSource <int>();

            process.Exited += (sender, args) => tcs.SetResult(process.ExitCode);

            var context = SynchronizationContext.Current;

            if (context != null)
            {
                process.OutputDataReceived += (sender, args) => context.Post(RunLog, args.Data);
                process.ErrorDataReceived  += (sender, args) => context.Post(RunLog, args.Data);
            }
            else
            {
                _log.Warn("Can't listen to process messages!");
            }

            var started = process.Start();

            if (!started)
            {
                throw new InvalidOperationException("Could not start process: " + process);
            }

            process.BeginOutputReadLine();
            process.BeginErrorReadLine();

            return(tcs.Task);
        }
Example #2
0
        private void AppendLibsInfo(VersionIndex vIndex, VersionDataIndex dIndex, List <DownloadTarget> list)
        {
            foreach (var libraryInfo in vIndex.Libraries)
            {
                if (!IndexTool.IsLibraryAllowed(libraryInfo))
                {
                    continue;
                }

                var relativePath = IndexTool.GetLibraryPath(libraryInfo);

                if (!dIndex.Libs.ContainsKey(relativePath))
                {
                    _log.Warn($"Data index does not contain library {libraryInfo.Name}");
                    continue;
                }

                var path     = Path.Combine(_librariesPath, relativePath);
                var url      = $"{_storeUrl}/libraries/{relativePath}";
                var fileInfo = dIndex.Libs[relativePath];

                list.Add(new DownloadTarget(path, url, fileInfo.Size, fileInfo.Hash));
            }
        }