Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is VB.NET Version of this Code?

if (InvokeRequired)
{
  BeginInvoke(new MethodInvoker(delegate()
  {
    textBox1.Text = args.Fax.Port.ToString();
    textBox2.Text = args.Fax.FaxStatus.ToString();
  }));
}
like image 482
beaudetious Avatar asked Apr 21 '10 15:04

beaudetious


1 Answers

From MSDN

Delegate Sub MyDelegate(myControl As Label, myArg2 As String)

Private Sub Button_Click(sender As Object, e As EventArgs)
   Dim myArray(1) As Object

   myArray(0) = New Label()
   myArray(1) = "Enter a Value"
   myTextBox.BeginInvoke(New MyDelegate(AddressOf DelegateMethod), myArray)
End Sub 

Public Sub DelegateMethod(myControl As Label, myCaption As String)
   myControl.Location = New Point(16, 16)
   myControl.Size = New Size(80, 25)
   myControl.Text = myCaption
   Me.Controls.Add(myControl)
End Sub 

So

if (InvokeRequired)
{
  BeginInvoke(new MethodInvoker(delegate()
  {
    textBox1.Text = args.Fax.Port.ToString();
    textBox2.Text = args.Fax.FaxStatus.ToString();
  }));
}

Delegate Sub MyDelegate(faxPort As String, faxStatus As String)

If InvokeRequired Then
    Dim aArray(1) as Object
    aArray(0) = args.Fax.Port.ToString()
    aArray(1) = args.Fax.FaxStatus.ToString();
    BeginInvoke(New MyDelegate(AddressOf MySub), aArray)
End If

Sub MySub( faxPort as String, faxStatus as String)
    textBox1.Text = faxPort
    textBox2.Text = faxStatus
End Sub

I think

like image 119
jcolebrand Avatar answered Nov 07 '22 07:11

jcolebrand