-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add common model for sync and async processing #1082
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
odinserj
changed the title
Add common model for sync and async processing
[WIP] Add common model for sync and async processing
Dec 20, 2017
Codecov Report
|
LogRetry(executionId, delay); | ||
|
||
#if NETFULL | ||
await await Task.WhenAny(_running.AsTask(_stopToken), Task.Delay(delay, _abortToken)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more await
s! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, more awaits is more reliable 🤡
Closed
odinserj
changed the title
[WIP] Add common model for sync and async processing
Add common model for sync and async processing
Mar 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR brings common model for executing both synchronous and asynchronous methods in background. This is the result of pain and frustration that accompanied me for several months, while I was trying hard to make this model robust even case of
ThreadAbortException
andThreadInterruptException
, simple to understand, maintain and operate, fully testable.Today I'm committing the first part of this work, related to basic primitives:
IBackgroundExecution
is to provide execution loops, exception handling and proper logging.IBackgroundDispatcher
to schedule work on thread pools, regardless of its nature, andBackgroundTaskScheduler
to be able to execute asynchronous work on dedicated threads that is close as possible to theThreadPoolTaskScheduler
.Soon I will create more commits that mix these abstractions with background processes and servers. This will result in the following improvements in the background processing:
info
level. This will allow to have a built-in logger for Event Log, and have fewer users who disable the logging.ThreadAbortException
orThreadInterruptException
. I know they shouldn't be used from user code, you know they shouldn't be called from user code. But bad things happen, and they will almost silently shutdown the processing. Now they are caught, aborts are reset when possible (but not during AppDomain unloads), andfatal
message is logged when this isn't possible.I didn't mention any features related to asynchronous execution, because full support for it requires storage interfaces to be asynchronous as well, and this will only be possible in 2.0 due to the breaking nature of these changes. However, custom processes can be made asynchronous now, so this will be useful anyway, and this is great step forward.
TaskScheduler
implementations, or limited only toThreadPool
(more on this in next item). This model will be based on piece of code you want to execute, and a configured concurrency. Dedicated threads or default thread pool – doesn't matter.Relates to #150.