The code i have so far is...
-
-
Friend Structure ProgressInformation
-
Public Size As UInt32
-
Public Start As UInt32
-
Public Reserved1 As UInt32
-
Public Reserved2 As UInt32
-
End Structure
-
-
Friend Enum ProgressEvent
-
ChipErase
-
Program
-
Verify
-
End Enum
-
-
<UnmanagedFunctionPointer(CallingConvention.StdCall)> _
-
Public Delegate Sub ProgressDelegate(ByVal progressEvent As ProgressEvent, ByVal state As ProgressInformation)
-
-
<DllImport(LIBRARY, EntryPoint:="SetProgressEvent ", CallingConvention:=CallingConvention.StdCall)> _
-
Friend Shared Sub SetProgressHandler(ByVal notifyHandler As ProgressDelegate)
-
' Empty method body
-
End Sub
-
-
I use the imported method as follows...
-
-
Private Sub UpdateProgress(ByVal progressEvent As ProgressEvent, ByVal state As ProgressInformation)
-
Console.WriteLine(progressEvent.ToString())
-
Console.WriteLine("Size:{0}, Start:{1}, Reserved1:{2}, Reserved2:{3}", state.Size, state.Start, state.Reserved1, state.Reserved2)
-
End Sub
-
-
...
-
Public Sub New()
-
.... other initialisation code here
-
-
SetProgressHandler(AddressOf UpdateProgress)
-
-
.... other dispose code here
-
End Sub
-
Now, the first time the UpdateProgress method runs i get valid data in the structure. As soon as the method returns, i get an AccessViolationException saying that the memory is corrupt. I'm thinking its something related to the way i've declared the import but i'm struggling to understand what.
Once again, thanks for any help in advance
Kev