public void GetImageRunCallback() { var imageGetter = new SimpleBitmapThumbnailGetter(100); var callbackCompleted = false; var processingDone = new ManualResetEventSlim(false); var result = imageGetter.BeginGetImage(ar => { Assert.IsNotNull(ar); Assert.IsTrue(ar.IsCompleted); var actualImage = imageGetter.EndGetImage(ar); var expected = _originalImage.GetThumbnailImage(100, 100, null, IntPtr.Zero); //not the same binary?? //AssertImagesAreEquivalent(expected, actualImage); callbackCompleted = true; processingDone.Set(); }, _file.FullName); Assert.IsFalse(callbackCompleted); //result.AsyncWaitHandle.WaitOne(); //doesn't wait for callback complete, just callback init Assert.IsTrue(processingDone.Wait(5000)); Assert.IsFalse(result.CompletedSynchronously); Assert.IsTrue(callbackCompleted); }
public void GetImageBlocking() { var imageGetter = new SimpleBitmapThumbnailGetter(100); var result = imageGetter.BeginGetImage(null, _file.FullName); var actualImage = imageGetter.EndGetImage(result); var expected = _originalImage.GetThumbnailImage(100, 100, null, IntPtr.Zero); //not the same binary?? //AssertImagesAreEquivalent(expected, actualImage); Assert.IsFalse(result.CompletedSynchronously); }