Creating a simple program to monitor changes to Network Adapter(s) status, vis:
Code:
Imports System
Imports System.Net
Imports System.Net.NetworkInformation
Public Class Form1

    Private Delegate Sub DoResults(ByVal nName As String, ByVal nStatus As String)

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AddHandler NetworkChange.NetworkAddressChanged, AddressOf AddressChangedCallback
        TextBox1.Text = "Monitoring for changes"
        TextBox1.AppendText(vbNewLine)
    End Sub

    Private Sub UpdateText(ByVal AdapterName As String, ByVal AdapterStatus As String)
        TextBox1.AppendText(AdapterName)
        TextBox1.AppendText(" ")
        TextBox1.AppendText(AdapterStatus)
        TextBox1.AppendText(vbNewLine)
    End Sub

    Private Sub AddressChangedCallback(ByVal sender As Object, ByVal e As EventArgs)
        Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
        Dim n As NetworkInterface
        For Each n In adapters
            Dim adResult As New DoResults(AddressOf UpdateText)
            Try
                adResult.Invoke(n.Name.ToString, n.OperationalStatus.ToString)
            Catch ex As Exception
                MessageBox.Show("Exception: " & ex.Message)
            End Try
        Next n
    End Sub
End Class
I'm getting an "Cross-thread operation not valid: Control Textbox1 accessed from a thread other than the thread it was created on" exception when I invoke the Delegate. Clearly there's a gap in my understanding; can someone perhaps explain what I ought to be doing ?