コード例 #1
0
 protected void RemoveDownload(DownloadItem d, bool shouldLock)
 {
     if (dwnItems.ContainsKey(d))
     {
         if (shouldLock)
         {
             System.Threading.Monitor.Enter(this);
         }
         try
         {
             FlowSortedList <Source> tmpDwn = dwnItems[d];
             if (tmpDwn != null)
             {
                 foreach (Source var in tmpDwn)
                 {
                     if (srcItems.ContainsKey(var))
                     {
                         FlowSortedList <DownloadItem> tmpSrc = srcItems[var];
                         if (tmpSrc != null)
                         {
                             tmpSrc.Remove(d);
                             if (tmpSrc.Count == 0)
                             {
                                 srcItems.Remove(var);
                             }
                         }
                     }
                 }
             }
             dwnItems.Remove(d);
         }
         finally
         {
             if (shouldLock)
             {
                 System.Threading.Monitor.Exit(this);
             }
         }
         DownloadRemoved(this, new FmdcEventArgs(0, d));
         d.DownloadCompleted -= d_DownloadCompleted;
         d.SegmentCanceled   -= d_SegmentCanceled;
         d.SegmentCompleted  -= d_SegmentCompleted;
         d.SegmentStarted    -= d_SegmentStarted;
     }
 }
コード例 #2
0
 protected void RemoveSource(Source s, bool shouldLock)
 {
     if (srcItems.ContainsKey(s))
     {
         if (shouldLock)
         {
             System.Threading.Monitor.Enter(this);
         }
         try
         {
             FlowSortedList <DownloadItem> tmpSrc = srcItems[s];
             if (tmpSrc != null)
             {
                 foreach (DownloadItem var in tmpSrc)
                 {
                     if (dwnItems.ContainsKey(var))
                     {
                         FlowSortedList <Source> tmpDwn = dwnItems[var];
                         if (tmpDwn != null)
                         {
                             tmpDwn.Remove(s);
                         }
                     }
                 }
             }
             srcItems.Remove(s);
         }
         finally
         {
             if (shouldLock)
             {
                 System.Threading.Monitor.Exit(this);
             }
         }
         SourceRemoved(this, new FmdcEventArgs(0, s));
     }
 }