Skip to content

Conversation

xlegalles
Copy link
Contributor

@xlegalles xlegalles commented Feb 10, 2025

#769
There is a slight behavior difference as the isRunning flag will only be set when the worker is effectively closed.

Copy link
Collaborator

@ChrisKujawa ChrisKujawa left a comment

Choose a reason for hiding this comment

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

Thanks 🚀

[Obsolete("Use DisposeAsync instead.", false)]
public void Dispose()
{
_ = DisposeAsync();
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓️ should we wait here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current implementation does not wait. This is what is problematic. But waiting an async method from a sync one is really not a good practice

Copy link
Collaborator

@ChrisKujawa ChrisKujawa Feb 10, 2025

Choose a reason for hiding this comment

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

After reading the docs:

I thought we might want to write the methods a bit differently and make sure we close/dispose all resources more directly. Especially after the reformat we see that there several objects, we are not keeping the reference to dispose them correctly. Speaking of the _. https://github.com/camunda-community-hub/zeebe-client-csharp/blob/main/Client/Impl/Worker/JobWorker.cs#L107-L111

I guess we could simply call dispose on them, like on the Task thats starts the polling, etc.

But I guess we still need the cancelation of the source - and disposing of it

_ = transformer.LinkTo(output);
var linkInputTransformer = input.LinkTo(transformer);
var linkTransformerOutput = transformer.LinkTo(output);

Copy link
Contributor Author

@xlegalles xlegalles Feb 11, 2025

Choose a reason for hiding this comment

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

Track polling Task in order to await for its completion. Note that I do not want to cancel the continuation. Finally, dispose TPL block objects.

}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update the signature so that we can pass the cancellation token to SendAsync


/// <inheritdoc />
public async ValueTask DisposeAsync()
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cancel the source token which will stop the pollingTask. Note that I've changed the log because it's not an error and very annoying to see it in reports.

Comment on lines +131 to +133

linkInputTransformer.Dispose();
linkTransformerOutput.Dispose();
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ Should we maybe dispose the objects in our dispose? But I guess this will not work in the error case.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants