[blam: 7/11] Lock all of the channel update, not just the end



commit 8c777e84c019ae8882a6e30d118419fade5901ac
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date:   Fri Aug 26 03:10:07 2011 +0200

    Lock all of the channel update, not just the end
    
    Signed-off-by: Carlos MartÃn Nieto <carlos cmartin tk>

 src/Channel.cs |   44 +++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index 006487f..e5cd17c 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -220,31 +220,29 @@ namespace Imendio.Blam {
          */
         public bool Update(SyndicationFeed feed)
         {
-            /* If our name is sub-optimal */
-            if((Name == "" || Name == Url) &&
-                feed.Title.Text != null) {
-                Name = HtmlUtils.StripHtml(feed.Title.Text.Trim());
-            }
+            lock(obj){
+                /* If our name is sub-optimal */
+                if((Name == "" || Name == Url) &&
+                   feed.Title.Text != null) {
+                    Name = HtmlUtils.StripHtml(feed.Title.Text.Trim());
+                }
 
-            LastRefreshed = DateTime.Now;
-
-            /*
-             * The new item list is just the new list, so create it
-             * on the spot
-             */
-            ArrayList nitems = new ArrayList();
-            foreach(SyndicationItem sitem in feed.Items){
-                Item item = new Item(sitem);
-                nitems.Add(item.Id);
-                /* If didn't have it already, add it to the store */
-                if(!item_list.Contains(item.Id))
-                    ItemStore.Add(item);
-            }
+                LastRefreshed = DateTime.Now;
+
+                /*
+                 * The new item list is just the new list, so create it
+                 * on the spot
+                 */
+                ArrayList nitems = new ArrayList();
+                foreach(SyndicationItem sitem in feed.Items){
+                    Item item = new Item(sitem);
+                    nitems.Add(item.Id);
+                    /* If didn't have it already, add it to the store */
+                    if(!item_list.Contains(item.Id))
+                        ItemStore.Add(item);
+                }
 
-            /*
-             * Delete the items that are no longer in the feed
-             */
-            lock(obj){
+                /* Delete the items that are no longer in the feed */
                 foreach(string id in item_list){
                     if(!nitems.Contains(id)){
                         ItemStore.Remove(id);



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