- Home /
Problem Using ThreadPool in Unity Android
So, I am using ThreadPool.QueueUserWorkItem to run the network intensive code in the background. The program is running without hitchup or lag in iOS device, but unfortunately the problem arise on Android Device. In Android device, there is some lag that can been seen on unity main thread, the game seems freeze for a second. This can be worst if there is no internet connection, which is the connection time out I set is around 15 second, the game freeze around 2-3 seconds. The code is as simple as below:
public static IEnumerator SomeMethod (System.Action<int, bool> callback) {
bool isDone = false;
ThreadPool.QueueUserWorkItem (state => {
try {
//doing network related logic here, establish connection, and post http
} catch (System.Exception e) {
D.Error (e.Message);
callback (0, false);
}
isDone = true;
});
while (!isDone) yield return null;
}
Can anybody pointed to me, why in android and iOS there are such difference behavior?
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
I can't Implement the Pool system 1 Answer
Invite friends facebook sdk unity android 1 Answer