Asyncoroutine icon indicating copy to clipboard operation
Asyncoroutine copied to clipboard

Task as coroutine just give us waiting after few tries

Open Haaxor1689 opened this issue 5 years ago • 0 comments

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;

Haaxor1689 avatar May 22 '19 07:05 Haaxor1689