In VB.Net, I have a process in a single sub that carries out certain checks and then sends messages. In carrying out the checks it calls a socket.Receive function to test the availability of a server.
This works well but takes about 3 to 5 seconds to run and could run up to 2000 times. Due to the time, I changed things so that the sub is called on different threads, with this code
Dim NewThread As New System.Threading.Thread(AddressOf StartTheProcess)
This works well if the sub is not called to quickly, once every second seems OK. But faster than this I get errors relating to the socket function.
My question is - if the sub is running multiple times, will there be multiple calls to the same socket function at the same time or is it separated in some way?
In general, in multithreading, if there is a function called from different threads, do they interact with the same function.
If this is the case, what is the way round it?
Thanks for any help.