Browse files

Merge remote branch 'garuma/pfx-fixes'

  • Loading branch information...
2 parents e7f148a + 5c0d538 commit 327ec1ddec5d6079aff945a2bbbd5d3fac266f90 @rubenv committed Apr 24, 2010
View
6 src/Core/Tripod.Core/Tripod.Model.Gui/PhotoGridViewChild.cs
@@ -27,6 +27,7 @@
// THE SOFTWARE.
using System;
+using System.Threading.Tasks;
using Tripod.Base;
using Tripod.Sources;
@@ -169,9 +170,6 @@ void Reload (IPhoto photo)
var loader = Core.PhotoLoaderCache.RequestLoader (photo);
last_loader_task = loader.FindBestPreview (ThumbnailWidth, ThumbnailHeight);
last_loader_task.ContinueWith ((t) => {
- if (t.IsCanceled)
- return;
-
var new_surface = PixbufImageSurface.Create (last_loader_task.Result);
var cache = (ParentLayout as PhotoGridViewLayout).SurfaceCache;
@@ -184,7 +182,7 @@ void Reload (IPhoto photo)
cache[photo] = new_surface;
(ParentLayout.View as PhotoGridView).InvalidateThumbnail (photo);
});
- });
+ }, TaskContinuationOptions.NotOnCanceled);
}
bool finding_larger = false;
View
12 src/Core/Tripod.Core/Tripod.Tasks/RefCountCancellableTask.cs
@@ -36,20 +36,14 @@ public RefCountCancellableTask (Func<T> function, CancellationTokenSource source
{
}
- int count = 0;
+ CountdownEvent count = new CountdownEvent (1);
public override void Cancel ()
{
if (IsCompleted || IsCanceled)
return;
- bool should_cancel = false;
- lock (this) {
- if (count > 0 && Interlocked.Decrement (ref count) == 0 && !IsCompleted)
- should_cancel = true;
- }
-
- if (should_cancel) {
+ if (count.Signal ()) {
try {
base.Cancel ();
} catch (TaskCanceledException) { }
@@ -58,7 +52,7 @@ public override void Cancel ()
public void Request ()
{
- Interlocked.Increment (ref count);
+ count.TryAddCount ();
}
}
}

0 comments on commit 327ec1d

Please sign in to comment.