[hyena] [Hyena.Downloader] More Finished catching



commit f9373d450c1566d94c11a8c054db6f33ed68c244
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Jul 14 11:45:14 2010 -0700

    [Hyena.Downloader] More Finished catching
    
    Catch Finished handler exceptions in the File and String downloaders
    too, and call the base.OnFinished last in String so the handlers are all
    called before the calling thread is unblocked.

 Hyena/Hyena.Downloader/HttpFileDownloader.cs   |   12 ++++++++----
 Hyena/Hyena.Downloader/HttpStringDownloader.cs |    9 +++++++--
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/Hyena/Hyena.Downloader/HttpFileDownloader.cs b/Hyena/Hyena.Downloader/HttpFileDownloader.cs
index 6c9e4e1..f613b1a 100644
--- a/Hyena/Hyena.Downloader/HttpFileDownloader.cs
+++ b/Hyena/Hyena.Downloader/HttpFileDownloader.cs
@@ -66,9 +66,13 @@ namespace Hyena.Downloader
         protected override void OnFinished ()
         {
             if (file_stream != null) {
-                file_stream.Close ();
-                file_stream = null;
-                OnFileFinished ();
+                try {
+                    file_stream.Close ();
+                    file_stream = null;
+                    OnFileFinished ();
+                } catch (Exception e) {
+                    Log.Exception (String.Format ("HttpFileDownloader.OnFinished ({0})", Uri), e);
+                }
             }
 
             base.OnFinished ();
@@ -82,4 +86,4 @@ namespace Hyena.Downloader
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/Hyena/Hyena.Downloader/HttpStringDownloader.cs b/Hyena/Hyena.Downloader/HttpStringDownloader.cs
index e1903cf..412d977 100644
--- a/Hyena/Hyena.Downloader/HttpStringDownloader.cs
+++ b/Hyena/Hyena.Downloader/HttpStringDownloader.cs
@@ -57,11 +57,16 @@ namespace Hyena.Downloader
 
         protected override void OnFinished ()
         {
-            base.OnFinished ();
             var handler = Finished;
             if (handler != null) {
-                handler (this);
+                try {
+                    handler (this);
+                } catch (Exception e) {
+                    Log.Exception (String.Format ("HttpStringDownloader.Finished handler ({0})", Uri), e);
+                }
             }
+
+            base.OnFinished ();
         }
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]