async void HandleGameSetChanged(Game x) { _settings.Ready = false; _settings.GameOptions.RecentGameSet = x == null ? null : new RecentGameSet(x); OnPropertyChanged(nameof(ActiveGame)); await TaskExt.StartLongRunningTask(() => TryActiveGameChanged(x)) .ConfigureAwait(false); }
Task RunInstaller() => TaskExt.StartLongRunningTask(() => { using (var p = Process.Start(_tmpFile, "-install")) { // /vREINSTALL=ALL /vREINSTALLMODE=vomus /v/qb p.WaitForExit(); } if (!IsInstalled()) { throw new InstallationFailed(); } });
async Task PerformUnpack() { _statusRepo.Action = RepoStatus.Unpacking; _progress.Reset(RepoStatus.Unpacking); await _restarter.TryWithUacFallback(TaskExt.StartLongRunningTask( () => Tools.Compression.Unpack(_sourceFile, _destination, true)), "files").ConfigureAwait(false); _progress.Update(null, 100); _statusRepo.UpdateProgress(90); }
public override Task Start(uint appId, Uri uri) { _uri = uri; var t2 = TaskExt.StartLongRunningTask(async() => { using (var drainer = new Drainer(uri)) { await drainer.Drain().ConfigureAwait(false); } }); // TODO: Test the connection? return(TaskExt.Default); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); _bootstrapper = new WpfAppBootstrapper(Environment.GetCommandLineArgs().Skip(1).ToArray(), Assembly.GetEntryAssembly().Location.ToAbsoluteFilePath().ParentDirectoryPath); _bootstrapper.Configure(); if (_bootstrapper.CommandMode) { HandleSingleInstance(); } _cmBs = new CMBootstrapper <string>(_bootstrapper); TaskExt.StartLongRunningTask(StartupInternal).WaitSpecial(); }
public virtual Task Run(IPEndPoint http, IPEndPoint https, CancellationToken cancelToken) { var urls = BuildUrls(http, https); var hostBuilder = new WebHostBuilder(); // .UseContentRoot(Directory.GetCurrentDirectory()) ConfigureBuilder(hostBuilder); hostBuilder.UseUrls(urls.ToArray()); var webHost = hostBuilder.Build(); return(TaskExt.StartLongRunningTask(() => webHost.Run(cancelToken), cancelToken)); }
public static Task RunningQueue <T>(this BlockingCollection <T> block, int maxThreads, Action <T> act) { var tasks = Enumerable.Range(1, maxThreads > 0 ? maxThreads : 1) .Select(x => TaskExt.StartLongRunningTask(() => { foreach (var item in block.GetConsumingEnumerable()) { act(item); } })); return(Task.WhenAll(tasks)); }
private static async Task <int> HandleNative(ISteamSessionLocator locator, bool inclRules, List <Tuple <string, string> > filter, Action <ArmaServerInfoModel> act) { var api = new SteamApi(locator); var degreeOfParallelism = inclRules ? 30 : 1; using (var bc = new BlockingCollection <ArmaServerInfoModel>()) { // TODO: better MT model var bcT = TaskExt.StartLongRunningTask(async() => { await Task.WhenAll(Enumerable.Range(1, degreeOfParallelism).Select(_ => Task.Run(async() => { foreach (var s in bc.GetConsumingEnumerable()) { await UpdateServerInfo(s, api, inclRules).ConfigureAwait(false); act(s); } }) )); }); var c2 = await api.GetServerInfo(locator.Session.AppId, x => { try { var ip = x.m_NetAdr.GetQueryAddressString().Split(':').First(); var ipAddress = IPAddress.Parse(ip); var map = x.GetMap(); var s = new ArmaServerInfoModel(new IPEndPoint(ipAddress, x.m_NetAdr.GetQueryPort())) { ConnectionEndPoint = new IPEndPoint(ipAddress, x.m_NetAdr.GetConnectionPort()), Name = x.GetServerName(), Tags = x.GetGameTags(), Mission = string.IsNullOrEmpty(map) ? null : x.GetGameDescription(), Map = map, Ping = x.m_nPing, MaxPlayers = x.m_nMaxPlayers, CurrentPlayers = x.m_nPlayers, RequirePassword = x.m_bPassword, IsVacEnabled = x.m_bSecure, ServerVersion = x.m_nServerVersion }; bc.Add(s); } catch (Exception ex) { Console.WriteLine(ex); } }, filter); bc.CompleteAdding(); await bcT; return(c2); } }
public static async Task SimpleRunningQueue <T>(this IEnumerable <T> items, int maxThreads, Action <BlockingCollection <T> > mainAct, Action <T> act) { var queue = new ConcurrentQueue <T>(items); using (var blockingCollection = new BlockingCollection <T>(queue)) { var syncTask = TaskExt.StartLongRunningTask(() => mainAct(blockingCollection)); var monitorTask = blockingCollection.RunningQueue(maxThreads, act); await syncTask.ConfigureAwait(false); blockingCollection.CompleteAdding(); await monitorTask.ConfigureAwait(false); } }
public static Task RunningQueue(this BlockingCollection <Action> block, int maxThreads, CancellationToken token = default(CancellationToken)) { var tasks = Enumerable.Range(1, maxThreads > 0 ? maxThreads : 1) .Select(x => TaskExt.StartLongRunningTask(() => { foreach (var item in block.GetConsumingEnumerable(token)) { item(); } }, token)); return(Task.WhenAll(tasks)); }
public static Task SimpleQueue <T>(this IEnumerable <T> items, int maxThreads, Action <T> act) { var queue = new ConcurrentQueue <T>(items); var tasks = Enumerable.Range(1, maxThreads > 0 ? Math.Min(maxThreads, queue.Count) : 1) .Select(x => TaskExt.StartLongRunningTask(() => { T item; while (queue.TryDequeue(out item)) { act(item); } })); return(Task.WhenAll(tasks)); }
private async Task OnlyCopyIfHashMisMatch(IAbsoluteFilePath source, IAbsoluteFilePath destination, ITProgress status) { if ( await TaskExt.StartLongRunningTask( () => HashEncryption.MD5FileHash(source) != HashEncryption.MD5FileHash(destination)) .ConfigureAwait(false)) { await CopyAsyncInternal(source, destination, true, status).ConfigureAwait(false); return; } this.Logger() .Info("Source and destination files equal. Source: {0}, Destination: {1}", source, destination); }
public static void Main(string[] args) { var entryAssembly = typeof(Program).GetTypeInfo().Assembly; MainLog.logManager = new Lazy <ILogManager>(() => new DummyLogManager()); var rootPath = entryAssembly.Location.ToAbsoluteFilePath().ParentDirectoryPath; CommonBase.AssemblyLoader = new AssemblyLoader(entryAssembly, null, rootPath); Common.Flags = new Common.StartupFlags(args, true); var bs = new CoreAppBootstrapper(args, rootPath); bs.Configure(); TaskExt.StartLongRunningTask(() => Start(bs)).WaitAndUnwrapException(); Console.WriteLine("Hello world!"); Console.ReadLine(); }
private void HandleUpdateStateInBackground() => TaskExt.StartLongRunningTask(Container.GetInstance <SelfUpdateHandler>().HandleUpdateState);
protected override Task ScanForLocalContentImpl() => TaskExt.StartLongRunningTask(() => ScanForLocalContentInternal());
public Task CleanAsync(IAbsoluteDirectoryPath workingDirectory, IReadOnlyCollection <IRelativePath> exclusions, IEnumerable <string> fileTypes, IAbsoluteDirectoryPath backupPath) => TaskExt.StartLongRunningTask(() => Clean(workingDirectory, exclusions, fileTypes, backupPath));
public Task CheckoutAsync(ProgressLeaf progressLeaf, bool confirmChecksums = true) => TaskExt.StartLongRunningTask(() => Checkout(progressLeaf, confirmChecksums));
private void TryHandleFirefoxInBackground() => BackgroundTasks.RegisterTask(TaskExt.StartLongRunningTask(() => TryHandleFirefox()));
public Task ReadLoop() => TaskExt.StartLongRunningTask(ReadLoopInternal, _token);
GetMissionsToDownload( IEnumerable <Mission> missions, IAbsoluteDirectoryPath destination, StatusRepo repo) => TaskExt.StartLongRunningTask(() => SumMissions(destination, missions.ToDictionary(x => x, x => (ITransferStatus) new Status(x.FileName, repo))));
private void TryInstallFlashInBackground() => TaskExt.StartLongRunningTask(InstallFlash);
static Task RestartExplorer() => TaskExt.StartLongRunningTask(() => RestartExplorerInternal());
public Task Run(CancellationToken token) => TaskExt.StartLongRunningTask(() => RunInternal(token), token);
private void InstallToolsInBackground() => TaskExt.StartLongRunningTask(InstallTools);
public Task CheckoutWithoutRemovalAsync(ProgressLeaf progressLeaf) => TaskExt.StartLongRunningTask(() => CheckoutWithoutRemoval(progressLeaf));
public Task <string> ProcessUserconfig(IAbsoluteDirectoryPath modPath, IAbsoluteDirectoryPath gamePath, string exisitingChecksum, bool force = true) => TaskExt.StartLongRunningTask(() => ProcessUserconfigInternal(modPath, gamePath, exisitingChecksum, force));
protected Task End() => TaskExt.StartLongRunningTask(EndInternal);
public Task Run() => TaskExt.StartLongRunningTask(RunInternal);
public Task <bool> ScanForGames() => TaskExt.StartLongRunningTask(() => ScanAllDrives());