Hi all I have a asyncronis server and on response I need to update texbox1 with it I googled and found out that you need a delegate sub I added it in several different ways but each time the program becomes unresponsive not sure what I am doing wrong it doesn't throw any errors.

Code:
Delegate Sub SetTextCallback([text] As String)

Private Sub SetText(ByVal [text] As String)

        ' InvokeRequired required compares the thread ID of the
        ' calling thread to the thread ID of the creating thread.
        ' If these threads are different, it returns true.
        If Me.TextBox1.InvokeRequired Then
            Dim d As New SetTextCallback(AddressOf SetText)
            Me.Invoke(d, New Object() {[text]})
        Else
            Me.TextBox1.Text = [text]
        End If
    End Sub

 Public Sub ReadCallback(ByVal ar As IAsyncResult)
        Dim content As String = String.Empty

        ' Retrieve the state object and the handler socket  
        ' from the asynchronous state object.  
        Dim state As StateObject = CType(ar.AsyncState, StateObject)
        Dim handler As Socket = state.workSocket

        ' Read data from the client socket.   
        Dim bytesRead As Integer = handler.EndReceive(ar)

        'Dim NewByte() As Byte = state.buffer.Reverse
        If bytesRead > 0 Then
            Dim ByteArray(256) As Byte
            Dim i As Integer = 0
            For Each Byte0 As Byte In state.buffer
                If Byte0 > 0 Then
                    ByteArray(i) = Byte0
                    i += 1
                End If
            Next

            ' There might be more data, so store the data received so far.  
            state.sb.Append(Encoding.ASCII.GetString(ByteArray, 0, bytesRead).Trim(Chr(0)).ToString())
        End If

        ' Check for end-of-file tag. If it is not there, read   
        ' more data.  
        content = state.sb.ToString()
        If content.EndsWith("<EOF>") Then
            Dim response As String = content
            response = content.Remove(0, 1)
            response = response.Replace("<EOF>", "").Trim

            'Gets to here invoke is required and app just freezes with no eerors
            If TextBox1.InvokeRequired Then
                Dim d As New SetTextCallback(AddressOf SetText)
                TextBox1.Invoke(d, New Object() {TextBox1})
            Else
                TextBox1.Text = Text
            End If

                   Else
            ' Not all data received. Get more.  
            handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, New AsyncCallback(AddressOf ReadCallback), state)
            End If
        '
    End Sub 'ReadCallback