Has anyone else out there had this error I get it when I exit the application that I wrote.
An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll
According the wise ones in Redmond, this error should never happen. Unfortunately, I am getting about 70% of the time when I close the application. I've found that if I comment out a certain line, the error goes away. Unfortunately, the line is one that I need to get the code right. I'll post the code here in a minute.
What this is supposed to do is fill a series of custom (number only) text boxes with readings from the sensors on a machine that we have. It does do that on form load, no problem. The problem comes when I exit this form. That's when I get the error. If I comment out the line about the syncronizing object (third line in Form1_Load) the error goes away, but the readings are sketchy. That won't work.
I could really use some help with this.
Thanks
Joe White
Private
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loaddio.closenozzles("DAQPad")
dio.closeport("DAQpad")
areader.SynchronizingObject =
Mecallback =
New AsyncCallback(AddressOf analogInCallback)areader.BeginReadMultiSample(100, callback,
Nothing) End Sub Private Sub analogInCallback(ByVal ar As IAsyncResult)Try 'Stop reading and pass the contents of the buffer 'to the array using the async callback
data = areader.EndReadMultiSample(ar)
NozzleTemp.Text = data(0, data.GetUpperBound(1))
MeterTemp.Text = data(1, data.GetUpperBound(1))
RH.Text = data(2, data.GetUpperBound(1))
Absolute.Text = data(3, data.GetUpperBound(1))
MNDiff.Text = data(4, data.GetUpperBound(1))
Vacuum.Text = data(5, data.GetUpperBound(1))
MeterDiff.Text = data(6, data.GetUpperBound(1))
RevSensor.Text = data(7, data.GetUpperBound(1))
areader.BeginReadMultiSample(100, callback,
Nothing)Array.Clear(data, 0, data.Length)
Catch ex As ExceptionMessageBox.Show(ex.Message)
ai.Dispose()
End Try End Sub

Execution Engine Error
samdalil
Lie
The onReadCompleted() method sounds like an event to get samples without using a separate thread. Again, look for code samples or contact the vendor to find out how to use it.
RGE
Here is the code I added. I'm still getting the same error at random places. Sometimes I get it at the exit of this form, sometimes at the exit of other forms that have no data acquistition in them. However, it is always at the exit of a form. I'm stumped. The thing that really sucks is that according to Microsoft, this is NEVER supposed to happen. That's not a lot of comfort right now though.
If
running = True ThenmyResult =
New AsyncCallback(AddressOf onCompletedRead) 'aitask.Stop()aitask.Dispose()
running =
False End IfPublic
Sub onCompletedRead(ByVal asyncResult As IAsyncResult)Array.Clear(data, 0, data.Length)
data = reader.EndReadMultiSample(myResult)
aitask.Stop()
End Sub