views:

47

answers:

2

I'm writing a .NET 4.0 library that should be efficient and simple to use.

The library is used by referencing it and using its different classes.

Should I use .NET 4.0 Tasks tot make things more efficient internally? I fear that it might make the usage of the library more complex and limited since the users might want to decide for themselves when and where to use tasks and threads.

If your answer depends on the kind of library, here is more information:

The library is Pcap.Net, which is a wrapper for WinPcap and includes a packet interpretation framework.

A: 

Should? Dunno. How about giving people an option by providing extension methods that use tasks against the library and push that out in a separate DLL? If you want to use tasks, reference the extension library and go crazy. Otherwise, stick with the core dll.

I believe there are many projects that follow this pattern with Linq. They provide their core library and a separate .Linq.DLL which has extension methods...

Will
+3  A: 

It only is an issue when the user can 'see' the threading, ie you give out access to data that could be accessed (by you) on another Thread. Probably not a good idea.

But when the parallel processing stays completely inside your application then there is very little chance your users would object.

Henk Holterman