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

Investigate the use of TaskCreationOptions.LongRunning #1318

Closed
lukebakken opened this issue Mar 21, 2023 · 7 comments · Fixed by #1321
Closed

Investigate the use of TaskCreationOptions.LongRunning #1318

lukebakken opened this issue Mar 21, 2023 · 7 comments · Fixed by #1321
Assignees
Milestone

Comments

@lukebakken
Copy link
Contributor

lukebakken commented Mar 21, 2023

Reported here:

https://groups.google.com/g/rabbitmq-users/c/9lFwM_xF5cw

Relevant discussion:

#959

@lukebakken lukebakken added this to the 6.5.0 milestone Mar 21, 2023
@lukebakken lukebakken self-assigned this Mar 21, 2023
@lukebakken lukebakken removed this from the 6.5.0 milestone Mar 21, 2023
@stebet
Copy link
Contributor

stebet commented Mar 21, 2023

It's not that simple. Task.Factory.StartNew does not support async methods which MainLoop will become eventually.

@lukebakken
Copy link
Contributor Author

lukebakken commented Mar 21, 2023

I figured there was a reason we're not using it.

@stebet for 6.x I'm assuming it's fine to make this change.

@lukebakken lukebakken added this to the 6.5.0 milestone Mar 21, 2023
@d-jagoda
Copy link

d-jagoda commented Mar 21, 2023

I believe it was conditionally used before but was removed by commit 311ef63

As for using async methods in Task.Factory.StartNew, it is possible to use them, you just have to unwrap the result task no? Which is exactly what Task.Run with async methods to. So it would be no different from using Task.Run except for minor differences which can be changed via TaskCreationOptions.

        var task = Task.Factory.StartNew(async () =>
        {
            await Task.Delay(TimeSpan.FromSeconds(10));
        });

        await task.Unwrap();
        // Or
        // var inner = await task;
        // await inner;

@Zerpet Zerpet linked a pull request Mar 22, 2023 that will close this issue
11 tasks
@Zerpet
Copy link
Contributor

Zerpet commented Mar 22, 2023

I figured there was a reason we're not using it.

@stebet for 6.x I'm assuming it's fine to make this change.

I'll be happy to keep this change for the 6.x branch, assuming it is not breaking change (as marked in #1321)

@d-jagoda
Copy link

I figured there was a reason we're not using it.
@stebet for 6.x I'm assuming it's fine to make this change.

I'll be happy to keep this change for the 6.x branch, assuming it is not breaking change (as marked in #1321)

Thanks, that will be great. I've unmarked it as breaking now.

I only marked it as breaking because there is a minor "observable behavior change in existing systems" where the task no longer runs on the threadpool.

@lukebakken
Copy link
Contributor Author

Fixed by #1321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants