Additional Control.Invoke overloads break Visual Basic Code
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
### .NET version
.NET 6+
### Did it work in .NET Framework?
Yes
### Did it work in any of the earlier releases of .NET Core or .NET 5+?
.NET 3.1
### Issue description
The new overloads we introduced for `Control.Invoke` breaks Visual Basic code.
This used to be OK before:
```VB
If String.IsNullOrEmpty(Me.Text) Then
>> Me.Invoke(Sub()
>> myDataGridForm.BindableDataGridView.DataSource = myDataSource
>> End Sub)
Return
End If
```
This does no longer work.

The reason is that the Visual Basic compiler automatically creates the expected type for a Lambda. So here, the identifier names represents the actual types, which the compiler automatically generates.

To correct this, we need to rewrite it and help the compiler to create the correct type like this (as one solution):
```VB
If String.IsNullOrEmpty(Me.Text) Then
Me.Invoke(New Action(
Sub()
myDataGrid.DataSource = myDataSource
End Sub))
Return
End If
```
### Steps to reproduce
Just try the above discussed code.
Contributor guide
Assessment
This issue has not been assessed yet.