So, there is a quick question to DEV team. Why Addressable system hasn’t any type of canceling it’s async operations? Is this just to be done in future release? Is is would be always like that?
internal System.Threading.Tasks.Task<TObject> Task
{
get
{
#if UNITY_WEBGL
Debug.LogError("Multithreaded operation are not supported on WebGL. Unable to aquire Task.");
return default;
#else
if (Status == AsyncOperationStatus.Failed)
{
return System.Threading.Tasks.Task.FromResult(default(TObject));
}
if (Status == AsyncOperationStatus.Succeeded)
{
return System.Threading.Tasks.Task.FromResult(Result);
}
var handle = WaitHandle;
return System.Threading.Tasks.Task.Factory.StartNew((Func<object, TObject>)(o =>
{
var asyncOperation = o as AsyncOperationBase<TObject>;
if (asyncOperation == null)
return default(TObject);
handle.WaitOne();
return (TObject)asyncOperation.Result;
}), this);
#endif
}
}
As we could see, this code is from AsyncOperationBase class, where we create new Task trough Task Factory, but don’t pass cancellation token, so in fact this Task could be killed only with Thread in which it’s executed.
Soooo. Why, and would it be changed in future releases, or should we handle all this by ourselves?