Re: Multi-Threaded 'Get' Example - WeOnlyDo Discussion board

Re: Multi-Threaded 'Get' Example (General questions)

by ActiveGreg, Monday, February 23, 2009, 19:44 (5547 days ago) @ wodDamir

Damba,

Much appreciated...

So I should set blocking to OFF, and capture the response in 'IwodHttpNotify_Done' when the call is done, such as:
strResponse=http(5).Response.Body?

Greg

Hi Greg,

Unfortunately, when declaring component as array, WithEvents statement is invalid. However, you can do something like this:

[code]Option Explicit
Dim http(5) As wodHttpDLXCom
Implements IwodHttpNotify

Private Sub Form_Load()
Dim i As Integer
For i = 0 To 4
Set http(i) = New wodHttpDLXCom
Set http(i).Notification = Me
Next
End Sub

Private Sub IwodHttpNotify_ClientCertRequired(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom)
End Sub

Private Sub IwodHttpNotify_Connected(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom)
End Sub

Private Sub IwodHttpNotify_Disconnected(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, ByVal ErrorCode As Long, ByVal ErrorText As String)
End Sub

Private Sub IwodHttpNotify_Done(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, ByVal ErrorCode As Long, ByVal ErrorText As String)
End Sub

Private Sub IwodHttpNotify_HeadersDone(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom)
End Sub

Private Sub IwodHttpNotify_HostCertificate(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, ByVal Cert As wodHttpDLXComLib.ICertificate, ByVal ErrorCode As Long, ByVal ErrorText As String, Accept As Boolean)
End Sub

Private Sub IwodHttpNotify_Progress(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, ByVal Position As Long, ByVal Total As Long)
End Sub

Private Sub IwodHttpNotify_Redirect(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, URL As String, Allow As Boolean)
End Sub

Private Sub IwodHttpNotify_StateChange(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, ByVal OldState As wodHttpDLXComLib.HttpStates)
End Sub

Private Sub IwodHttpNotify_Progress64(ByVal Owner As wodHttpDLXComLib.IwodHttpDLXCom, ByVal PositionLo As Long, ByVal PositionHi As Long, ByVal TotalLo As Long, ByVal TotalHi As Long)
End Sub
[/code]

In this sample, I used Notification interface. In this case, each method (event) has Owner parameter which provides you with reference to instance of component that raised the event. Can you try something like that?

As for using blocking, you're correct. Each method that is executed will block the rest of the code until it finishes executing. To avoid that you should use Events.

Regards,
Damba


Complete thread: