cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

async usage in examples

async usage in examples

Tzach K.
New member | Level 1

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()?

5 Replies 5

Re: async usage in examples

Greg-DB
Dropboxer

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.

Re: async usage in examples

Tzach K.
New member | Level 1

Hi Gregory,

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?

Thank you for your answer.

Re: async usage in examples

Qiming Y.
Dropboxer

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.

 

Re: async usage in examples

Tzach K.
New member | Level 1

Hi Qiming,

 

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.

 

Re: async usage in examples

Qiming Y.
Dropboxer

Thanks for your feedback Tzach! We will add more documentation for the examples.

Poll
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?
Who's talking

Top contributors to this post

  • User avatar
    Qiming Y. Dropboxer
  • User avatar
    Tzach K. New member | Level 1
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?