Reputation: 2246
The error is raised randomly in my code. There's so stacktrace available
It's more common when when RaisedPropertyChanged
is called such as
public IImageProvider IForeground
{
get { return BlendifierEffect.ForegroundSource; }
set
{
if (BlendifierEffect.ForegroundSource != value)
{
BlendifierEffect.ForegroundSource = value;
updateImageBlending();
RaisedPropertyChanged();
}
}
}
So I commented out the RaisedPropertyChanged()
method call but it's still being raised once in a while.
The updateImageBlending()
is a method which just re-render the effect if any of the blending properties is changed.
private async void updateImageBlending()
{
if (IsRendering)
{
return;
}
if (SelectedPicture == null)
{
return;
}
if (SelectedPicture.Index < 3)
{
return;
}
if (SelectedEffect == null )
{
IImageProcessor noEffect = FilterEffects.FirstOrDefault();
if (noEffect != null)
{
RenderResult renderResult = await imageProcessorRenderer.RenderAsync(noEffect, RenderOption.RenderToSoftwareBitmap | RenderOption.RenderAtPreviewSize);
imageProcessorRenderer.BlendBackground = renderResult.SoftwareBitmap;
IBackground = new SoftwareBitmapImageSource(imageProcessorRenderer.BlendBackground);
}
else
{
return;
}
}
Dispatcher.Dispatch(() => { IsRendering = true; });
SoftwareBitmap softwareBitmap = null;
softwareBitmapRenderer.Size = imageProcessorRenderer.PreviewSize;
softwareBitmapRenderer.RenderOptions = RenderOptions.Cpu;
softwareBitmap = await softwareBitmapRenderer.RenderAsync();
Dispatcher.Dispatch(async () =>
{
WriteableBitmapPreview = await convertPreviewToWriteableBitmap(softwareBitmap, null);
});
Dispatcher.Dispatch(() => { IsRendering = false; });
}
softwareBitmapRender
takes a BlendEffect
and is initialized in the beginning.
if (BlendifierEffect == null)
{
BlendifierEffect = new BlendEffect();
BlendifierEffect.GlobalAlpha = 0.5d;
BlendifierEffect.BlendFunction = BlendFunction.Normal;
BlendifierEffect.TargetOutputOption = OutputOption.PreserveAspectRatio;
BlendifierEffect.TargetArea = new Rect(0d, 0d, Scale, Scale);
}
if (softwareBitmapRenderer == null)
{
softwareBitmapRenderer = new SoftwareBitmapRenderer(BlendifierEffect);
}
BlendEffect
is updated as user change its properties such as
public IImageProvider Mask
{
get { return BlendifierEffect.MaskSource; }
set
{
if (BlendifierEffect.MaskSource != value)
{
BlendifierEffect.MaskSource = value;
updateImageBlending();
}
}
}
What is causing the error and how do I catch it or disable it?
Upvotes: 0
Views: 58