- Home /
How can I send http request from not-main thread?
When i try do this, compiler give me this error
StartCoroutine_Auto can only be called from the main thread
or this error when call WWWForm form = new WWWForm();
RandomRangeInt can only be called from the main thread
Answer by Narv · Feb 07, 2014 at 03:42 PM
Can't really see what's wrong with your code without your code being posted, however:
Unity does not directly support threads. Everything must be called from the main thread. However, if you wish to use threads for certain calls, you will have to use a producer / consumer (or similar) algorithm for processing the data in a thread, but then store it in a queue for the main thread to process on each iteration through. You will need to be careful with this though to avoid race conditions and will need to implement locks and such on the queue (and associated variables you wish to send between threads).
If you let us know what it is you are trying to implement we will be able to assist you better with an implementation theory and code.
Your answer
Follow this Question
Related Questions
Dynamic content delivery on Unity iOS 0 Answers
Unity3D WWW call on main thread on iOS 0 Answers
How to use the new IMultipartFormSection in a UnityWebRequest.Post 2 Answers
prevent UnityWebRequest.Post() from Url-Encoding the data ? 1 Answer
Unity HTTP Post WebRquest not working on some Android Devices 0 Answers