SendQueue stacks methods in a queue and calls them sequentially, not immediately.
SendQueue can be used similarly to asynchronous methods because it operates in an additional thread.
Precautions when using SendQueue
SendQueue is a method to stack methods in a queue and execute them one by one in an additional thread.
In short, methods are not called immediately but they are executed in order of the queue.
If multiple methods are stacked in SendQueue, the response of the method that was inserted last may be delayed because it is called much later.
The callback method of SendQueue was designed to be executed in Unity's main thread.
Therefore, unlike asynchronous methods, you can access Unity objects, UI objects, etc. within the callback method.
Situations where methods must be stacked in SendQueue.
- It is recommended for most situations.
- When the order of method calls must be ensured
- When issues of final reading consistency need to be avoided while calling multiple methods
Situations where methods must not be stacked in SendQueue
- When a request must be sent as soon as a method is called
- When the data of the current user must be stored when closing the game