Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Avoid capturing ExecutionContext into CancellationTokenSource's Timer #18670

Merged
merged 2 commits into from
Jun 28, 2018

Conversation

stephentoub
Copy link
Member

It's not needed, and it can keep unrelated state alive unnecessarily.

Contributes to https://github.com/dotnet/corefx/issues/26523
Contributes to https://github.com/dotnet/corefx/issues/30670

cc: @kouvel, @tarekgh, @benaadams

It's not needed, and it can keep unrelated state alive unnecessarily
object state,
int dueTime,
int period,
bool flowExecutionContext)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you didn't make this internal for now and we can expose it later? why we need to have UnsafeCreate at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just following the proposed API, which maps to things like ThreadPool.QueueUserWorkItem vs ThreadPool.UnsafeQueueUserWorkItem. I don't have a strong preference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really preferring the constructor over UnsafeCreate. having flowExecutionContext parameter is more useful to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@tarekgh
Copy link
Member

tarekgh commented Jun 27, 2018

I added one question, other than that LGTM

@stephentoub stephentoub merged commit 7d72463 into dotnet:master Jun 28, 2018
@stephentoub stephentoub deleted the timerunsafecreate branch June 28, 2018 14:26
@benaadams
Copy link
Member

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…dotnet/coreclr#18670)

* Avoid capturing ExecutionContext into CancellationTokenSource's Timer

It's not needed, and it can keep unrelated state alive unnecessarily

* Address PR feedback


Commit migrated from dotnet/coreclr@7d72463
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants