Skip to content
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

Long-running tasks using factory #399

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Core/src/Eventuous.Shared/Tools/TaskRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class TaskRunner(Func<CancellationToken, Task> taskFactory) : IDis
Task? _runner;

public TaskRunner Start() {
_runner = Task.Run(Run);
_runner = Task.Factory.StartNew(Run, _stopSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);

return this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public ValueTask Write(T element, CancellationToken cancellationToken)
protected ChannelWorkerBase(Channel<T> channel, Func<CancellationToken, Task> processor, int concurrencyLevel, bool throwOnFull = false) {
_channel = channel;
_throwOnFull = throwOnFull;
_readerTasks = Enumerable.Range(0, concurrencyLevel).Select(_ => Task.Run(() => processor(_cts.Token))).ToArray();

_readerTasks = Enumerable.Range(0, concurrencyLevel)
.Select(_ => Task.Factory.StartNew(() => processor(_cts.Token), _cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default))
.ToArray();
}

public async ValueTask DisposeAsync() {
Expand Down
Loading