Error 170 indicates “device in use”. Without that retry loop I got regularly an error on my test computer. I was deliberating if it was better to simply ignore that error or rather do a retry. My tests indicated that it lasted 500 to 700 ms for that condition to clear so I decided to do a retry.
I suspect that WLanScan() does actually very little in reality. The Windows WLan service will scan the networks regularly anyhow. When that error occurs it is most likely just doing that. Normally, WLanScan is propably just a little tickle for the service to remind it that there is still a client present. In the unlikely case that the service hasn’t performed a scan already for some time it will trigger one but otherwise just return a no error code to say “yes I did it”.