- Home /
Cancel WWW post operation
Is it possible to cancel a WWW operation once it has been started?
Good question. I'm not sure what happens when you just "null" the reference to the www instance. If it works you can't use yield of course since yield will store the reference in the coroutine and there's no way to release it (maybe StopCoroutine but that's not a good approach imho).
You can use a coroutine that checks isDone in a loop. This loop can be aborted by your own condition.
But that's all just guessing. It's definitely something that should be included in the www class.
Thanks for that, Bunny83. I have tried using a top level while loop with a cancel condition, which seems to stop the routine but not the www operation. Unfortunately I'm afraid I can't stop the coroutine since it requires 3 args, and there's no clean way to rewrite it down to one so I can start it with the string method of StartCoroutine (and thereby stop it).,
Well, you don't have to stop it, just make sure that the www reference isn't passed to the coroutine handler and null it. It will take some time until the garbage collector removes it.
Suddenly it came to my $$anonymous$$d that is could work with Destroy(www).
Answer by Dreamora · Jul 24, 2011 at 11:12 PM
You can stop a request as it takes place. To do so you make use of WWWs inheritance as it inherits from IDisposable, which allows you to call
wwwObject.Dispose ();
to basically destroys it forcefully. But be aware that WWW does more than just download. Audio, Texture and AssetBundles are automatically loaded once downloaded and if you dispose that, hell can break lose basically.
Your answer
Follow this Question
Related Questions
Stop instance 1 Answer
Any way to stop a build? 3 Answers
How to stop coroutine with parameters? 3 Answers
How do I keep an increment process continuous without the update function? 2 Answers
How do I use RESTful apis from Unity? 0 Answers