B4J Question Using Wait For for 2 different events

lancaster

Member
Licensed User
Longtime User
I need to trap both HTTP POST 'success' and 'error' conditions within a single sub...

I'm currently using OkHttp to POST API calls to a service and I have 2 Wait For statements as follows:

Wait For postRequest_ResponseError ( ....)
(some code)

Wait For postRequest_ResponseSuccess ( ...)
(some code)

As these events are mutually exclusive it appears I only resume after the first one. If the job is successful, control is never returned to my sub.

Is is possible to wait for one of two mutually exclusive events like this?

Thanks for any help.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

lancaster

Member
Licensed User
Longtime User
Hi Manfred,

Thanks.

I did look at using the okHttpUtils library but I need to use okHttpClient.InitializeAcceptAll to handle HTTPS certificate issues and that doesn't exist in the replacement libraries.

Hence that why I'm still using OkHttpClient.

Dave Lancaster
 
Upvote 0

lancaster

Member
Licensed User
Longtime User
and it's an excellent solution thanks. Has simplified the code significantly and once you also deal with headers and cookies 'after' the HttpJob.PostString call (which seemed a little illogical until it worked) ... ;)

Thanks.
 
Upvote 0
Top