G
Guest
Hi,
i'm trying to grasp the concept of syncronizing threads, but without success
Here is the situation:
I'm using an object which connects to a server. After connection i want to
send informational requests.
If i send a request and the object is not connected yet i tell the Component
to connect(sub RequestInfo).
But before sending the request i have to wait until the connection succeded.
This is told to me by a Event (Sub Open_Result)
There are 2 options 1 is by using doEvents() in a loop, but that is using up
resources, the second is syncronizing Threads.
Could anyone help me?
Thanks in advance!
Rob Smeets
See below for simplified sample
Class GetInfo
Private withevents objInformationService as New InformationService
Private Connected as boolean = False
private Sub Connect()
objInformationService.Connect("UserName", "Password")
end sub
Private Sub RequestInfo(SelectStatement as string)
If Me.connected = False then
Me.Connect()
End if
objInformationService.RequestInfo(SelectStatement)
End sub
Private Sub Open_Result(Result as integer, ErrorMessage as string) handles
objInformationService.Openresult
If result = 1 then
Connected = True
Else
msgbox ErrorMessage
end if
End Sub
End Class
i'm trying to grasp the concept of syncronizing threads, but without success
Here is the situation:
I'm using an object which connects to a server. After connection i want to
send informational requests.
If i send a request and the object is not connected yet i tell the Component
to connect(sub RequestInfo).
But before sending the request i have to wait until the connection succeded.
This is told to me by a Event (Sub Open_Result)
There are 2 options 1 is by using doEvents() in a loop, but that is using up
resources, the second is syncronizing Threads.
Could anyone help me?
Thanks in advance!
Rob Smeets
See below for simplified sample
Class GetInfo
Private withevents objInformationService as New InformationService
Private Connected as boolean = False
private Sub Connect()
objInformationService.Connect("UserName", "Password")
end sub
Private Sub RequestInfo(SelectStatement as string)
If Me.connected = False then
Me.Connect()
End if
objInformationService.RequestInfo(SelectStatement)
End sub
Private Sub Open_Result(Result as integer, ErrorMessage as string) handles
objInformationService.Openresult
If result = 1 then
Connected = True
Else
msgbox ErrorMessage
end if
End Sub
End Class