Make Umbraco.Cms.Infrastructure.HostedServices.RecurringHostedServiceBase methods virtual
#16495
Closed
PeterKvayt
started this conversation in
Features and ideas
Replies: 1 comment
-
|
Here is pull request |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I faced with the following issue: RecurringHostedServiceBase class has has abstract method PerformExecuteAsync. This method called as callback in Timer.
Let's imagine that we set
Thread.CurrentThread.CurrentUICulturein Main in Program.cs file as "en-GB", but by defaultThread.CurrentThread.CurrentUICulturehas "en-US" (it takes culture from machine region settings, but it doe not matter).During Timer creating
Thread.CurrentThread.CurrentUICulturehas "en-GB" culture, but when PerformExecuteAsync start executing, new thread is created and this new thread has default culture = "en-US".So if i want to have "en-GB" during PerformExecuteAsync, I need in my background task implementation (which inherited from RecurringHostedServiceBase) explicitly one more time setup
Thread.CurrentThread.CurrentUICultureas "en-GB".I think it is not good. It could be easily solved if methods were virtual.
What I am suggesting: it is not to bad to make virtual StartAsync, StopAsync, ExecuteAsync.
As I can see in release-13.3.2 methods StartAsync, StopAsync are already virtual. I am using umbraco
10.8.1, and as I can see for now umbraco10 latestdoes not has this methods as virtual. Also it is important to make ExecuteAsync method as virtual too.Beta Was this translation helpful? Give feedback.
All reactions