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

32 views Asked by At

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)
1

There are 1 answers

0
Enigmativity On BEST ANSWER

Try this:

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