13

Closed

Support Asynchronous Operations

description

Being that this library deals with I/O, I recommend adding support for asynchronous operations. Use the Asynchronous Programming Model (APM), which is standard throughout the .NET Framework.
 
Async operations are already available on GZipStream, DeflateStream, and ZlibStream in the Ionic.Zlib namespace.
But we need Async versions of Save and ExtractAll for the ZipFile class. And possibly Read.
 
For any library used in any environment that needs to scale, blocking on I/O is unacceptable.
Closed Oct 21, 2009 at 11:51 PM by Cheeso
This capability is now available, via the ZipInputStream and ZipOutputStream classes.

comments

Shane32 wrote May 25, 2009 at 8:20 PM

This would be very nice. It's easy enough to work around, but a built-in approach would be easier to use and probably more efficient.

Cheeso wrote Sep 3, 2009 at 11:15 PM

I know a bunch of people up-voted this and I'd like to know what exactly people expect. The two longest-running methods on the ZipFile class are Save and ExtractAll(), in the various overloads. I could provide async versions of these but wouldn't it be simpler for the caller to just do it themselves, using a BeginInvvoke on an Action delegate?

Action a = zip.Save;
a.BeginInvoke(MyAsynchSaveCompleted, null);

and then

private void MyAsynchSaveCompleted(IAsyncResult ar)
{
Action a = (ar as System.Runtime.Remoting.Messaging.AsyncResult).AsyncDelegate as Action;
try
{
a.EndInvoke(ar);
}
catch(Exception e)
{
// ...
}
}

or even with QueueUserWorkItem() if tracking exceptions isn't important.


There is a school of design that recommends that classes DO NOT provide async interfaces, because it is better to maintain a separation of concerns.

I'm interested in feedback.

mlowne wrote Sep 30, 2009 at 1:44 PM

Heres my opinion
I would prefer the async operations to be provided in the library - there are plenty of sync and async overloaded methods within the .Net framework.

It does appear to look very simple to do manually - but providing the methods means people get a very easy discoverable way of of how to do it and hopefully some excellent examples.

Some people may see that people should discover how to do it manually and therefore improve their skills. That is a strong argument. But I like things to be easy if the library provides support I will probably try to use it first.

I believe it will be a nice feature add of your library.