Surely you only need to know how threads work then and then thread the application so that you have x number of threads scanning x number of ports at anyone time so if some take longer than others its not gonna hold up the application greatly

for x:totalports
make thread[x]
result = with thread[x] use functionscanwith(port x) return something
end

obviously you need to handle what happens at the end of the threads, thats the challenging part

have fun!

i2c