Variables:
Source and Destination are both bitmaps that are the same size
hgt and wid are the height and width of the images minus 1
Here's the background worker Code:
The exception is "System.InvalidOperationException: Object is currently in use elsewhere."Code:Private Sub BGWProcess_DoWork(sender As Object, e As DoWorkEventArgs) Handles BGWProcess.DoWork` For Y = 0 To hgt For X = 0 To wid If BGWProcess.CancellationPending Then Exit Sub Destination.SetPixel(X, Y, Source.GetPixel(X, Y)) 'Here is where it fails Next BGWProcess.ReportProgress(Y) Next End Sub Private Sub BGWProcess_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BGWProcess.ProgressChanged TxtProgress.Text = e.ProgressPercentage.ToString PictureBox1.Image = Destination End Sub
at the line "Destination.SetPixel(X, Y, Source.GetPixel(X, Y))
There is nothing else going on that might be accessing any of the bitmaps or the PictureBox. Any ideas would be greatly appreciated.




Reply With Quote
