Asyncoroutine
Asyncoroutine copied to clipboard
Task as coroutine just give us waiting after few tries
Hi, I am using your library for executing async tasks in Editor. It's running as a coroutine on an on-demand instantiated game object with static getter. First, I'm using the UnityWebRequest
to send a request and wait for a response, which works fine. But then if I try to run a long-running task in the background, like parsing the response which can take up to a second, first few tasks run ok, but the for no reason the task is suddenly not registering that it completed until I interact with an editor.
In the example, getRequest
is resolved UnityWebRequest
. The MessagePaskSerializer.Deserializer
call is the long-running task that I want to run non-blocking.
var data = getRequest.downloadHandler.data;
var parseResponseTask = Task.Run(() => MessagePackSerializer.Deserialize<PostResponseModel>(data)).AsCoroutine();
yield return parseResponseTask;
response = parseResponseTask.Result;