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);
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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)));
        }
Exemplo n.º 4
0
        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
                };
            }
        }
Exemplo n.º 5
0
        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();
            }
Exemplo n.º 7
0
        // 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); });
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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();
                }
            }
        }
Exemplo n.º 10
0
            public void TracksEventWhenAppResumed()
            {
                var backgroundService = new BackgroundService(TimeService, AnalyticsService);

                backgroundService.EnterBackground();
                backgroundService.EnterForeground();
                AnalyticsService.Received().AppDidEnterForeground.Track();
            }
Exemplo n.º 11
0
        /********************************************************************************************
        * Constructors
        ********************************************************************************************/

        public PlotterUIToolTests()
        {
            BackgroundService = new BackgroundService();
            BackgroundService.SetWorker(new Workers.SingleQQ());

            PlotterUITool = new PlotterUITool();
            PlotterUITool.SetJobOrganizer(BackgroundService);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 15
0
        public void ManipulateInMediumDecayWidthVariables()
        {
            BackgroundService.SetWorker(WorkerLoader.CreateInstance("InMediumDecayWidth"));
            BackgroundService.TransferDataToWorker(ParameterSamples.InMediumDecayWidthSamples);

            AssertHelper.AssertAllElementsEqual(
                ParameterSamples.InMediumDecayWidthSamples, BackgroundService.GetDataFromWorker());
        }
Exemplo n.º 16
0
        public void ManipulateQQonFireVariables()
        {
            BackgroundService.SetWorker(WorkerLoader.CreateInstance("QQonFire"));
            BackgroundService.TransferDataToWorker(ParameterSamples.QQonFireSamples);

            AssertHelper.AssertAllElementsEqual(
                ParameterSamples.QQonFireSamples, BackgroundService.GetDataFromWorker());
        }
Exemplo n.º 17
0
        private void ReapplyBackgroundBonus(PerkType perkType)
        {
            var player = GetPC();

            if (IsGrantedByBackground(perkType))
            {
                BackgroundService.ApplyBackgroundBonuses(player);
            }
        }
Exemplo n.º 18
0
        void LoadNextBackground()
        {
            levelWarnerManager.IncreaseLevel();
            backgroundTickTime = 0;

            nextContextProps = BackgroundService.SetPropsForBackgroundContext(propsPool, currentBackgroundContext, maxPropsAmount, backgroundDisplay);

            hasNextContextLoaded = true;
        }
Exemplo n.º 19
0
        private BackgroundService CreateDummyBackgroundService()
        {
            BackgroundService service = new BackgroundService();

            service.SetWorker(new DummyWorker());
            service.JobFailure  += RegisterExeption;
            service.JobFinished += RegisterJobFinished;

            return(service);
        }
Exemplo n.º 20
0
        public void BackgroundServiceJobFailureEvent()
        {
            BackgroundService.SetWorker(WorkerLoader.CreateInstance("SingleQQ"));
            BackgroundService.JobFailure += RegisterJobFailure;
            BackgroundService.RequestNewJob(
                "CalculateBoundWaveFunction", new Dictionary <string, string>());

            WaitForJobFailure(2000);

            Assert.IsTrue(HasRegisteredJobFailure);
        }
Exemplo n.º 21
0
 private async Task HandleBackgroundException(BackgroundService backgroundService)
 {
     try
     {
         await backgroundService.ExecuteTask.ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         _logger.BackgroundServiceFaulted(ex);
     }
 }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
 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));
 }
Exemplo n.º 24
0
        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();
        }
Exemplo n.º 25
0
        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;
        }
Exemplo n.º 26
0
        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;
        }
Exemplo n.º 27
0
        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());
        }
Exemplo n.º 28
0
            public void DoesNotEmitAnythingWhenItHasNotEnterBackgroundFirst()
            {
                bool emitted           = false;
                var  backgroundService = new BackgroundService(TimeService, AnalyticsService, UpdateRemoteConfigCacheService);

                backgroundService
                .AppResumedFromBackground
                .Subscribe(_ => emitted = true);

                backgroundService.EnterForeground();

                emitted.Should().BeFalse();
            }
Exemplo n.º 29
0
 public void Inject(
     BackgroundService service,
     IUiService uis,
     ItemsService itemsService,
     DialogsService dialogs,
     StateService state)
 {
     _service      = service;
     _uiService    = uis;
     _itemsService = itemsService;
     _dialogs      = dialogs;
     _state        = state;
 }
Exemplo n.º 30
0
        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();
        }
Exemplo n.º 31
0
 public static void SetServiceBinder(BackgroundService.ControllerServiceBinder value)
 {
     _binder = value;
 }