rspec/rules/S4583/why-dotnet.adoc
Cristian Ambrosini dafa102cc0
Modify rule S4583: Update to LaYC (#2185)
## Review

A dedicated reviewer checked the rule description successfully for:

- [ ] logical errors and incorrect information
- [ ] information gaps and missing content
- [ ] text style and tone
- [ ] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
2023-06-14 15:44:31 +02:00

8 lines
669 B
Plaintext

== Why is this an issue?
When calling the `BeginInvoke` method of a https://learn.microsoft.com/en-us/dotnet/api/system.delegate[delegate], resources are allocated that are only freed up when `EndInvoke` is called. Failing to pair `BeginInvoke` with `EndInvoke` can lead to https://en.wikipedia.org/wiki/Resource_leak[resource leaks] and incomplete asynchronous calls.
This rule raises an issue in the following scenarios:
* The `BeginInvoke` method is called without any callback, and it is not paired with a call to `EndInvoke` in the same block.
* A callback with a single parameter of type `IAsyncResult` does not contain a call to `EndInvoke` in the same block.