I am using WriteableBitmapEx in a WinRT project. I am loading an image in WriteableBitmap from a user image library. However, I cannot immediately write this image, if I do, it will be overwritten by the image itself (it looks like Async loads the image, and then on top of its image on top of it). I don't know how to stop him from doing this (I tried using Await in SetSource, but not Async method).
I used "Await Task.Delay (1000)" and it works, but it seems to be hacked because 1000 ms may or may not be enough. I would like it to wait for the bitmap to load before continuing.
Could someone seem on top of what I'm doing wrong, or suggest how can I guarantee that WriteableBitmap is loaded from the image library before doing any processing? Here is an example of a piece of code that I created:
Dim file = Await picker.PickSingleFileAsync
If file Is Nothing Then
Exit Sub
End If
Dim wbm As New WriteableBitmap(1, 1)
wbm.SetSource(Await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
' If I don't have this, the DrawLine will not show up, if I do, it will.
Await Task.Delay(1000)
wbm.DrawLine(1, 1, 255, 255, Colors.Green)
wbm.Invalidate()
ImageMain.Source = wbm
source
share