views:

106

answers:

3

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

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?

+2  A: 

This is entirely up to you.

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.

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.

Reed Copsey
A: 

I would avoid asynchronous calls within a library like this.

What if the user of the library doesn't care about blocking? What if it's a command-line script that should block?

The threading of an application is a major design decision, avoid making for them.

I would first implement the blocking, synchronous calls and perhaps later, add asynchronous methods to make the library easier to use for thread-shy programmers.

Ben S
+1  A: 

This is a judgement call on your end. Consider, however:

  1. The user can always use a BackgroundWorker to avoid blocking, if you only expose in a synchronous way.

  2. If you feel that you can provide some intermediary data during the action (like progress percentage) then an asynchronous version may be useful.

John Gietzen