FINALLY - I am moving to the latest Xojo, working in macOS 10.14 Mojave, after using RealStudio 2011r3 for the past 8 years (which has been very successful for me). I find that I have to do very little to get it to work, mostly fixing my threading cheating (altering UI elements in a thread).
In that light, there is one major violation (I think) which doesn’t throw any exceptions, and you’ll see why. I’d like to know what would be the best fundamental way to refactor this. It’s a pretty simple question; I’m just making it sound complicated.
I use REAL/Xojo mostly to serve as a front end, although I do plenty within it. But most of the work of my app(s) is in a DYLIB/DLL, which does long operations and calls a callback function in my REAL/XOjo UI app to display progress.
This is the process I use, and it works great on Mac and Windows, using 2011r3, but I very much suspect it does not - causes hard crashes - in Xojo.
[code]Function FakeWorkFunc() As Integer
// not called within a thread
Soft Declare Function DoConvert Lib “conversionengine.dylib” (Inst1 As Integer, Inst2 As Integer) As Integer
Dim Param1, Param2 As Integer
Dim ErrCode As Integer
// function takes say 10 minutes. It calls the Xojo-contained callback function (it has the address)
ErrCode = DoConvert(Param1, Param2)
return ErrCode
End Function
Function ProgressCallback(Buff As Ptr) As Integer
// decodes Buff into a MemoryBlock and essentially gets a string and float out of it
// never mind how
Dim ProgressText As String
Dim ProgressAmt As Single
frmProgress.txtProgress.Text = ProgressText
frmProgress.ProgresBar1.Value = ProgressAmt * 1000
return 1
End Function[/code]
I think obviously the DYLIB/DLL banging on the UI thread while it’s still held up with the called function, is NOT GOOD.
And, additionally, I have some Xojo-based functions which the DYLIB/DLL calls - not UI related - where it gets some work done.
So, smart people everywhere, how would you refactor this so it wold play ball with the more thread-safe nature of the latest Xojo?