public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { _cts = new CancellationTokenSource(); Task.Run(() => { try { //INVOKE THE SHARED CODE var backgroundTask = new BackgroundService(); backgroundTask.RunBackgroundTask(_cts.Token).Wait(); } catch (Android.OS.OperationCanceledException) { } finally { if (_cts.IsCancellationRequested) { var message = new CancelMessage(); Device.BeginInvokeOnMainThread( () => MessagingCenter.Send(message, "CancelledMessage") ); } } }, _cts.Token); return(StartCommandResult.Sticky); }
private void UpdateViewCollection() { DispatcherTimer dispatcherTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(5000) }; dispatcherTimer.Tick += (s, e) => { dispatcherTimer.Stop(); if (VideoItemViewCollection == null) { return; } BackgroundService.Execute(() => { lock (Padlock) { this.IsLoading = true; LoaderCompletion.FinishCollectionLoadProcess(VideoItemViewCollection, FilePageDispatcher); } }, String.Format("Checking and updating files info in {0}", CurrentVideoFolder.Name), () => { this.IsLoading = false; }); }; dispatcherTimer.Start(); }
public async static Task <bool[]> BulkIsDialogue(this string[] Strings, int?Caution = null, bool UseAcceptableRanges = true) { if (BackgroundService == null) { if (Quotes == null || AcceptableRanges == null) { Console.Error.WriteLine("Settings Not Ready Yet."); } var lIgnoreList = IgnoreList; var lDenyList = DenyList; var lBeginAcceptableRanges = (from x in AcceptableRanges select x.Begin).ToArray(); var lEndAcceptableRanges = (from x in AcceptableRanges select x.End).ToArray(); var lPontuationList = new string(PontuationList); var lSpecialList = new string(SpecialList); var lOpenQuotes = new string((from x in Quotes select x.Start).ToArray()); var lCloseQuotes = new string((from x in Quotes select x.End).ToArray()); var lPontuationJapList = new string(PontuationJapList); var lSensitivity = Engine.Settings.Sensitivity; var lFromAsian = Engine.Settings.FromAsian; var lAllowNumbers = Engine.Settings.AllowNumbers; var lBreakline = Engine.Settings.Breakline; var Worker = await Engine.Worker.CreateAsync(); BackgroundService = await Worker.CreateBackgroundServiceAsync <StringsService>(); await BackgroundService.RunAsync((s) => s.Initialize(lIgnoreList, lDenyList, lBeginAcceptableRanges, lEndAcceptableRanges, lPontuationList, lSpecialList, lOpenQuotes, lCloseQuotes, lPontuationJapList, lSensitivity, lFromAsian, lAllowNumbers, lBreakline)); } return(await BackgroundService.RunAsync((s) => s.IsDialogue(Strings, Caution, UseAcceptableRanges))); }
public CoreProcessorBase(IUnityContainer container) { lock (LockObject) { Container = container; if (SetupDone == false) { //Container = container; //TODO: maybe all of thse should go outside of the "SetupDone" check and run everytime. ApplicationStartup = container.Resolve <ApplicationStartup>(); EventService = container.Resolve <EventService>(); DataService = container.Resolve <DataService>(); AuditService = container.Resolve <AuditService>(); BackgroundService = container.Resolve <BackgroundService>(); UserContext = container.Resolve <UserContext>(); PopulateDefaultValues(); SetupDone = true; BackgroundService.StartBackgroundJobs(); } JSON_SETTINGS = new JsonSerializerSettings { DateFormatString = WebsiteUtils.DateFormat }; } }
public App( ViewModelFactory viewModelFactory, PageFactory pageFactory, Func <Page, NavigationPage> navigationPageFactory, BackgroundService backgroundService, IThemeService themeService) { InitializeComponent(); _backgroundService = backgroundService; RequestedThemeChanged += (s, e) => { themeService.CurrentTheme = e.RequestedTheme switch { OSAppTheme.Dark => ThemeType.Dark, OSAppTheme.Light => ThemeType.Light, _ => ThemeType.System }; themeService.ApplyCurrentTheme(); }; themeService.ApplyCurrentTheme(); var vm = viewModelFactory(typeof(CreationListPageViewModel), null); var page = pageFactory(typeof(CreationListPage), vm); var navigationPage = navigationPageFactory(page); navigationPage.BarBackgroundColor = Color.Red; navigationPage.BarTextColor = Color.White; MainPage = navigationPage; }
public void TracksEventWhenAppGoesToBackground() { var backgroundService = new BackgroundService(TimeService, AnalyticsService, UpdateRemoteConfigCacheService); backgroundService.EnterBackground(); AnalyticsService.Received().AppSentToBackground.Track(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, BackgroundService backgroundService, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } var date = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time")).ToString("yyyy-MM-dd_HH-mm"); loggerFactory.AddFile($"Logs/myapp-{date}.txt"); Log.LoggerFactory = loggerFactory; app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute(name: "api", template: "api/{controller=Forecast}"); routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); Task.Run(async() => { var cts = new CancellationTokenSource(); await backgroundService.StartAsync(cts.Token); }); }
public async Task Start() { _cts = new CancellationTokenSource(); _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LongRunningTask", OnExpiration); try { //INVOKE THE SHARED CODE var backgroundTask = new BackgroundService(); await backgroundTask.RunBackgroundTask(_cts.Token); } catch (OperationCanceledException) { } finally { if (_cts.IsCancellationRequested) { var message = new CancelMessage(); Device.BeginInvokeOnMainThread( () => MessagingCenter.Send(message, "CancelledMessage") ); } } UIApplication.SharedApplication.EndBackgroundTask(_taskId); }
private async Task TryExecuteBackgroundServiceAsync(BackgroundService backgroundService) { // backgroundService.ExecuteTask may not be set (e.g. if the derived class doesn't call base.StartAsync) Task backgroundTask = backgroundService.ExecuteTask; if (backgroundTask == null) { return; } try { await backgroundTask.ConfigureAwait(false); } catch (Exception ex) { // When the host is being stopped, it cancels the background services. // This isn't an error condition, so don't log it as an error. if (_stopCalled && backgroundTask.IsCanceled && ex is OperationCanceledException) { return; } _logger.BackgroundServiceFaulted(ex); if (_options.BackgroundServiceExceptionBehavior == BackgroundServiceExceptionBehavior.StopHost) { _logger.BackgroundServiceStoppingHost(ex); _applicationLifetime.StopApplication(); } } }
public void TracksEventWhenAppResumed() { var backgroundService = new BackgroundService(TimeService, AnalyticsService); backgroundService.EnterBackground(); backgroundService.EnterForeground(); AnalyticsService.Received().AppDidEnterForeground.Track(); }
/******************************************************************************************** * Constructors ********************************************************************************************/ public PlotterUIToolTests() { BackgroundService = new BackgroundService(); BackgroundService.SetWorker(new Workers.SingleQQ()); PlotterUITool = new PlotterUITool(); PlotterUITool.SetJobOrganizer(BackgroundService); }
public static IExtrinsicCall ContractCall(this BackgroundService service, IApplication application, Func <IContractCallParameter> contractParameter) { var parameter = contractParameter(); var call = CallCall.Create(0, 200000000000, parameter, application.Serializer); return(call); }
public HomeController(ILocalHueClient hueClient, ILoggerFactory loggerFactory, Microsoft.Extensions.Hosting.IHostedService backgroundService, IStorageService storageService, IOptionsMonitor <Options> optionsAccessor) { _hueClient = hueClient; _loggerFactory = loggerFactory; _backgroundService = (BackgroundService)backgroundService; _storageService = storageService; _options = optionsAccessor.CurrentValue; }
private void InitFinishCollection() { DispatcherService.ExecuteTimerAction(() => { BackgroundService.Execute(() => { LoaderCompletion.FinishCollectionLoadProcess(PlayListCollection, null); }, "Getting playlist metadata...", () => { }); }, 5000); }
public void ManipulateInMediumDecayWidthVariables() { BackgroundService.SetWorker(WorkerLoader.CreateInstance("InMediumDecayWidth")); BackgroundService.TransferDataToWorker(ParameterSamples.InMediumDecayWidthSamples); AssertHelper.AssertAllElementsEqual( ParameterSamples.InMediumDecayWidthSamples, BackgroundService.GetDataFromWorker()); }
public void ManipulateQQonFireVariables() { BackgroundService.SetWorker(WorkerLoader.CreateInstance("QQonFire")); BackgroundService.TransferDataToWorker(ParameterSamples.QQonFireSamples); AssertHelper.AssertAllElementsEqual( ParameterSamples.QQonFireSamples, BackgroundService.GetDataFromWorker()); }
private void ReapplyBackgroundBonus(PerkType perkType) { var player = GetPC(); if (IsGrantedByBackground(perkType)) { BackgroundService.ApplyBackgroundBonuses(player); } }
void LoadNextBackground() { levelWarnerManager.IncreaseLevel(); backgroundTickTime = 0; nextContextProps = BackgroundService.SetPropsForBackgroundContext(propsPool, currentBackgroundContext, maxPropsAmount, backgroundDisplay); hasNextContextLoaded = true; }
private BackgroundService CreateDummyBackgroundService() { BackgroundService service = new BackgroundService(); service.SetWorker(new DummyWorker()); service.JobFailure += RegisterExeption; service.JobFinished += RegisterJobFinished; return(service); }
public void BackgroundServiceJobFailureEvent() { BackgroundService.SetWorker(WorkerLoader.CreateInstance("SingleQQ")); BackgroundService.JobFailure += RegisterJobFailure; BackgroundService.RequestNewJob( "CalculateBoundWaveFunction", new Dictionary <string, string>()); WaitForJobFailure(2000); Assert.IsTrue(HasRegisteredJobFailure); }
private async Task HandleBackgroundException(BackgroundService backgroundService) { try { await backgroundService.ExecuteTask.ConfigureAwait(false); } catch (Exception ex) { _logger.BackgroundServiceFaulted(ex); } }
public void BackgroundService_GetActiveBackgrounds_ShouldReturn5Active() { // Arrange var service = new BackgroundService(_db, _, _perk, _skill); // Act var results = service.GetActiveBackgrounds().ToList(); // Assert Assert.AreEqual(5, results.Count); }
private void UpdateViewCollection() { if (SearchResults.Count == 0) { return; } BackgroundService.Execute(() => { //this.IsLoading = true; LoaderCompletion.FinishCollectionLoadProcess(SearchResults, SearchPageDispatcher); }, String.Format("Updating files from search {0} result(s). ", ResultText)); }
void Start() { currentContextProps = BackgroundService.SetPropsForBackgroundContext(propsPool, currentBackgroundContext, maxPropsAmount, backgroundDisplay); for (int i = 0; i < currentContextProps.Count; i++) { currentContextProps[i].gameObject.SetActive(true); } ChangeBackgroundColor(); lastBackground = BackgroundService.GetLastBackground(); }
public void ProcessParameterFile_SingleQQ() { string lastParameterFile = YburnConfigFile.LastParaFile; WriteTestParaFile(ParameterSamples.SingleQQSamples); BackgroundService.SetWorker(WorkerLoader.CreateInstance("SingleQQ")); BackgroundService.ProcessParameterFile(TestParameterFileName); AssertCorrectProcessing(ParameterSamples.SingleQQSamples); YburnConfigFile.LastParaFile = lastParameterFile; }
public void ProcessParameterFile_InMediumDecayWidth() { string lastParameterFile = YburnConfigFile.LastParaFile; WriteTestParaFile(ParameterSamples.InMediumDecayWidthSamples); BackgroundService.SetWorker(WorkerLoader.CreateInstance("InMediumDecayWidth")); BackgroundService.ProcessParameterFile(TestParameterFileName); AssertCorrectProcessing(ParameterSamples.InMediumDecayWidthSamples); YburnConfigFile.LastParaFile = lastParameterFile; }
private void Start() { //we multiply by 2 since we want the bottom of the background to hit the screenTop //for such, the top of the background has to hit two the size of the screen top. screenTop = ScreenPositionService.GetTopEdge(Camera.main).y * 2; currentBackgroundContext = BackgroundContextEnum.Surface_1; currentBackground = BackgroundService.GetBackground(backgroundsPool, currentBackgroundContext); BackgroundService.SetPropsForBackgroundContext(backgroundPropsPool, ref currentBackground); StartCoroutine(SlideBackground()); }
public void DoesNotEmitAnythingWhenItHasNotEnterBackgroundFirst() { bool emitted = false; var backgroundService = new BackgroundService(TimeService, AnalyticsService, UpdateRemoteConfigCacheService); backgroundService .AppResumedFromBackground .Subscribe(_ => emitted = true); backgroundService.EnterForeground(); emitted.Should().BeFalse(); }
public void Inject( BackgroundService service, IUiService uis, ItemsService itemsService, DialogsService dialogs, StateService state) { _service = service; _uiService = uis; _itemsService = itemsService; _dialogs = dialogs; _state = state; }
public override async void Execute() { await Task.Delay(1000); ViewManager.Initialize(); SaveManager.Initialize(); ShortcutService.Initialize(); BrushService.Initialize(); DrawService.Initialize(); BackgroundService.Initialize(); CameraService.Initialize(); ProjectService.Initialize(); AudioPeerService.Initialize(); }
public static void SetServiceBinder(BackgroundService.ControllerServiceBinder value) { _binder = value; }