x


Wait for file download

Hello everyone,

I have some objects who needs the content of a downloaded file. I have an object who download the file. This object has a method like "GetGoodContent" which is called on "Start" in the first objects. Is it possible to do the following behaviour. And how ?

  • In the object Start() call "GetGoodContent".
  • First starts the download.
  • When the download is complete return the correct data from "GetGoodContent" to the caller object and not continue the execution of the function.

On first call of "GetGoodContent" start the download and wait for the download is complete and retrieve the good data in the file. My actual problem is that when i call "GetGoodContent" the file is downloaded but the execution continues, and the data can't be filed in my objects. I need to wait the download to be completed.

Thanks a lot !

more ▼

asked Jul 11 '12 at 08:51 PM

MaT. gravatar image

MaT.
76 4 9 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You really don't want to stop everything to wait for that download. The point of coroutines and 'yield' is to allow the game to continue, and you can process the downloaded data when it's done downloading. In JS you do that after the 'yield', in CS you do that in a coroutine which is called once the data is done downloading. Your game doesn't have to progress (you can not have it do anything real until you get the 'all clear' from your post-yield or coroutine). So if you need it to appear to do nothing, then set a boolean variable like 'downloaded' and have other things not happen if downloaded is false. Set downloaded true once you have processed the downloaded data.

more ▼

answered Jul 11 '12 at 11:24 PM

DaveA gravatar image

DaveA
26.4k 151 171 256

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x524
x333
x241
x195

asked: Jul 11 '12 at 08:51 PM

Seen: 407 times

Last Updated: Jul 11 '12 at 11:24 PM