vb.netbegininvoke

Threads: Multiple BeginInvoke(Sub() ...) -> programming style; Are tasks better?


i have made a litte programm. It has plenty of such lines:

    Me.BeginInvoke(Sub() Me.GroupBox1.Visible = False)
    Me.BeginInvoke(Sub() Me.txtVerfahrensbezeichnungValue.Visible = False)

Are there better ways because all of variables are pointing to a GUI style element?

I tried this (but it failed):

    Dim a = New With {
        Me.GroupBox1.Visible = False
        Me.txtVerfahrensbezeichnungValue.Visible = False
        }
    Me.BeginInvoke(a)

Solution

  • Try this:

    Me.BeginInvoke(Sub()
            Me.GroupBox1.Visible = False
            Me.txtVerfahrensbezeichnungValue.Visible = False
        End Sub)