Note that there are some explanatory texts on larger screens.

plurals
  1. POAsynchronous socket library not updating form
    text
    copied!<p>I am attempted to write a small asynchronous socket library that I can use to create a client/server application. I can get all of the code to run fine if I leave it in the form, however if I try to move it out into its own class, I cannot figure out how to update the form with connection status, things like that. Below is code, shortened a bit just to make this easier to read and type.</p> <p>Form Code:</p> <pre><code>Class Form1 Dim Network as NetworkModule Public Sub Button1_Click(Sender, e) Handles Button1.Click Network = New NetworkModule("127.0.0.1", 1234) End Sub End Class 'Form1 </code></pre> <p>NetworkModule class:</p> <pre><code>Class NetworkModule Private mSocket as Socket Public Sub New(IP as string, Port as Integer) Dim remoteEP as New IPEndpoint(IP.Parse(IP), Port) mSocket = New Socket(internetwork, stream, tcp) mSocket.BeginConnect(remoteEP, New AsyncCallback(AddressOf onConnect), mSocket) Notify("Connection to " &amp; remoteEP.ToString) 'This one works End Sub 'New Private Sub onConnect(ar as IAsyncResult) mSocket = CType(ar.AsyncState, Socket) mSocket.EndConnect(ar) Notify("Connected") 'This one never shows End Sub 'onConnect Private Delegate Sub _Notify(Msg as String) Private Sub Notify(Msg as String) If Form1.txtLog.InvokeRequired Then Form1.txtLog.Invoke(New _Notify(AddressOf Notify), Msg) Exit Sub End if Form1.txtLog.Text &amp;= Msg &amp; vbcrlf End Sub 'Notify End Class 'NetworkModule </code></pre> <p>There is actually more to that class, but I never get anything after the first message goes out. I'm not sure where to go from here. I've tried lots of different methods that I've found on the google searches, some from here, some not. Anybody have any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload