Bastion
Task.Delay vs. SpinWait.SpinOnce
Is there any performance loss/difference compared between using Task.Delay (allocating multiple task objects? that allocate a internal timer?) vs. SpinWait.SpinOnce?
The specific context I want to take, for example: A loop that receives data from a TCP socket server from clients. I don't necessarily need to save each socket, it just connects, sends (my app as server read the data) and closes the connection.
In this context, would SpinWait be more recommended or even use Task.Delay to control the current task's wait?
And in a context then i need to store these sockets for constantly processing (they will not connect early unless have an error or client ask for disconnection)
24 replies