我应该提供同步或异步方法,开发人员在我的IMDB API库? [英] Should I provide Sync or Async methods for developers in my IMDB API library?

查看:151
本文介绍了我应该提供同步或异步方法,开发人员在我的IMDB API库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会做一个DLL库,将alow开发搜索和访问IMDB电影页。

I'm going to make a DLL Library that'll alow developers to search and access IMDB movie pages.

我应该如何处理在GUI冻结,我应该使用异步方法,或者我应该让一个开发手动创建一个线程使用我们的DLL?

How should I handle the freezing in the GUI, should I use async methods, or should I allow a dev to manually create a thread for using our DLL?

推荐答案

这是完全取决于你。

话虽这么说,我想提供一个异步和同步API将让您的图书馆的行为更像框架库,这将给你的用户正确地使用它的最佳机会。

That being said, I think providing an asynchronous and a synchronous API will make your library act more like the framework libraries, which will give your users the best chance of using it correctly.

例如,Web客户端提供 DownloadFile DownloadFileAsync 。我个人而言,模仿我的API此行为。如果以异步方式实现你的图书馆,它很容易将保鲜膜这在同步API。

For example, WebClient provides DownloadFile and DownloadFileAsync. I would, personally, mimic this behavior in my API. If you implement your library asynchronously, it's very easy to wrap this in a synchronous API.

这篇关于我应该提供同步或异步方法,开发人员在我的IMDB API库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆