I have a question regarding the API v2 examples as a whole. All of the examples supplies use async calls. even for login. However you use task.wait() after the Task creation which essentially makes the call synchronous as the program waits for the task to complete.
You use async threads if those threads do operations that are independent of the main path or other threads(not including sharing information from those threads). What is the idea behind using it to perform login and task.wait()?
Are you asking why the decision was made to use task.wait() in that case? I can't say off hand (since I didn't write the example), but if you have any particular feedback I'll be happy to send it along to the team.
I'm saying that the code example doesn't make sense. On one hand you are using async calls, but then you tell the main thread to wait for the async thread to finish, meaning you turned it into sync calls. Then why use async to begin with?
The other thing I didn't get is why you display an async call for user login. How can this be an async call? you can't do anything before the user is logged in. Same goes for other examples you provide. All of them are async but with blocking task.wait and no explanation on why you used async.to begin with. Is it because you want to show a loading gif while waiting? then why block it?
The sdk provides async interface to all api calls. The example is a simple console application so the main function has to wait for the top level async call to complete. But this is not equivalent to making every api call blocking. Although the top level async task is blocking, it can still contain multiple parallel running async tasks which are non-blocking. In general any function involves network call should be async so that we can call them in parallel for better IO utilization. The login function also falls into the same category.
We say the same thing. I agree that for network you want to use async calls.
My main issue is that examples provided by DropBox should help developers understand how to build applications using your API. The explanation you provided in your answer is what needs to accompany your examples, or provide a full example.
Thanks for your feedback Tzach! We will add more documentation for the examples.
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?