我应该提供同步或异步方法,开发人员在我的IMDB API库?我的、开发人员、方法、API

2023-09-07 00:50:23 作者:捕获一只小可爱

我会做一个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.

 
精彩推荐
图片推荐