I have a job object for long running operations that works like this:
Class LongRunningJob
Inherits BackgroundWorker
Protected Overrides Sub OnDoWork(ByVal e As System.ComponentModel.DoWorkEventArgs)
'do long running job here
End Sub
End Class
And I invoke this like so:
Dim job As New LongRunningJob
'run it
job.RunWorkerAsync()
This worked fine a year ago, and I moved on to other things. I had to return to this code today, and when I run it now, the OnDoWork override is simply not called. A breakpoint in there isn’t hit, debugging messages aren’t written, the method is simply not called, and no errors are thrown anywhere.
I can’t think what would have changed that could cause this, since it seems like a low level framework thing. The rest of the app loads and runs fine, the main window shows (it’s a WPF app), and button click events fire. It’s just the background thread method that doesn’t fire. What could be going on here?
Well, I figured out how to fix the problem, although I’m not really sure what’s really going on here. If I left the OnDoWork routine empty:
it would be called, and if I put basic framework stuff in there, it would also be called. But as soon as I added a line like this:
the routine would not be called. I looked at the project for
AnotherLibrary, which is authored by me as well, looked at theCompile Tab, theTarget CPUdropdown and saw that it saidx86. I changed it toAny CPUand that fixed the problem. But I’d still like to know what that really means and why it caused this problem.