void _worker_DoWork(object sender, DoWorkEventArgs e) { WorkerArgs args = (e.Argument as WorkerArgs); if (args == null) { return; } lock (_launchTimingLock) { _lastLaunchInitiatedUtc = DateTime.UtcNow; } int serverIndex = 0; System.Collections.Concurrent.ConcurrentQueue <LaunchItem> globalQueue = args.ConcurrentLaunchQueue; int serverTotal = globalQueue.Count; if (serverTotal == 0) { return; } LaunchItem launchItem = null; var accountLaunchTimes = _gameSessionMap.GetLaunchAccountTimes(); while (globalQueue.TryDequeue(out launchItem)) { LaunchManager mgr = new LaunchManager(_launcherLocation, launchItem, accountLaunchTimes); mgr.ReportStatusEvent += (status, item) => HandleLaunchMgrStatus(status, item, serverIndex, serverTotal); LaunchManager.LaunchManagerResult launchResult; GameSession session = null; try { session = _gameSessionMap.StartLaunchingSession(launchItem.ServerName, launchItem.AccountName); UpdateAccountStatus(ServerAccountStatusEnum.Starting, launchItem); launchResult = mgr.LaunchGameHandlingDelaysAndTitles(_worker); } finally { _gameSessionMap.EndLaunchingSession(launchItem.ServerName, launchItem.AccountName); } if (launchResult.Success) { ++serverIndex; // Let's just wait for game monitor to check if the character list changed // b/c the AccountManager is subscribed for that event //CallUiNotifyAvailableCharactersChanged(); // Pick up any characters - experimental 2017-04-10 // CallUiLoadUserAccounts(); // Pick up any characters - before 2017-04-10 _gameSessionMap.StartSessionWatcher(session); workerReportProgress("Launched", launchItem, serverIndex, serverTotal); } if (_worker.CancellationPending) { e.Cancel = true; return; } } }
void _worker_DoWork(object sender, DoWorkEventArgs e) { WorkerArgs args = (e.Argument as WorkerArgs); if (args == null) { return; } lock (_launchTimingLock) { _lastLaunchInitiatedUtc = DateTime.UtcNow; } _serverIndex = 0; System.Collections.Concurrent.ConcurrentQueue <LaunchItem> globalQueue = args.ConcurrentLaunchQueue; _serverTotal = globalQueue.Count; if (_serverTotal == 0) { return; } LaunchItem launchItem = null; var accountLaunchTimes = _gameSessionMap.GetLaunchAccountTimes(); while (globalQueue.TryDequeue(out launchItem)) { int threadDelayMs = ConfigSettings.GetConfigInt("ThreadGameLaunchDelayMs", 100); Thread.Sleep(threadDelayMs); new Thread((x) => { Thread.CurrentThread.IsBackground = true; launchGameFromItem(args, (LaunchItem)x, accountLaunchTimes); }).Start(launchItem); if (_worker.CancellationPending) { e.Cancel = true; return; } } }