ZapRecorder 2 - Fix for 'TestProfile'
Hi BadWolf. I love the ZapRecorder program, thanks for doing that.
I see your 'TestProfile' functionality is commented out. I uncommented it, and saw the problems you have with 'Unable to read bytes' when getting various WoW bits.
I really wanted this functionality, so I started to incorporate it into FightThisWay, the custom class I wrote... and VERY early on, encountered the same bug, and what caused it. I fixed it, and figured you'd like to know what the fix was too, so you can fix ZapRecorder.
Basically - a form had a timer, that was trying to update the UI. I believe this caused a separate thread of execution, that sometimes successfully got the information from the underlying class, and sometimes didn't. When it didn't, it would throw that 'Unable to read bytes' error. The 'hacky' way I fixed it first, was to check 'StyxWoW.Me.IsValid' - that fixed it, but it is a hack.
The final solution, was to remove the timer, and raise an event called 'UpdateUI' from the underlying class itself. The form ONLY updates itself with fresh HonorBuddy information when it gets that event - otherwise, it does nothing. This causes the code to execute from the thread of the class, instead of the thread of the UI, and I was able to remove the 'StyxWoW.Me.IsValid' check. Raising this event from the 'Pulse' event of the plugin would work, with your product.
It's not obvious that the form is not on the same thread of execution as the DLL, but that appears to be the case. I freely admit that multi-threaded programming is something I shy away from - it's too easy to introduce impossible-to-trace bugs. I might be wrong in the particulars in this case, but raising an event from the Pulse event DID fix it for my product, anyway.
I hope this information helps your product as well.
--Kamilche