How add event ContentReceived to URLConnection by code?

Hi.
in DesktopWindow.opening I have:

Var urlCon As New URLConnection
urlCon.Send("GET", "https://....", 30)

How can add by code the ContentReceived event handle ?

A link for learn how to do it ? Thanks.

You’ll need to use AddHandler, but keep in mind that you will also need to make the urlcon variable into a property of the class or module that you are working in to keep it from going out of scope.

1 Like

Hi Greg.
Ok, work fine:

Var urlCon As New URLConnection
urlCon.Send("GET", "https://...", 30)
AddHandler urlCon.ContentReceived, AddressOf urlVersionOnlineReceived

Private Sub urlVersionOnlineReceived(sender As URLConnection, URL As String, HTTPStatus As Integer, content As String)
  .. my code ..
End Sub