S4583: FP with BeginInvoke / EndInvoke

Version used:

  • SonarQube 8.7
  • SonarLint for VS2015, version
    Doing an aynchronous invoke on an action appears to incorrectly identify that it is not paired with an Endinvoke.
Action a = () => { };
a.BeginInvoke(a.EndInvoke, null);

It appars that it can be solved by writing the code like this instead (which should be equivalent):

Action a = () => { };
a.BeginInvoke(ar => a.EndInvoke(ar), null);

Is this a known problem?

Hi @MichaelNebel

We can confirm the false positive. I`ve created an issue on sonar-dotnet and you can track the progress here: https://github.com/SonarSource/sonar-dotnet/issues/4255

Thanks for your feedback!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.