Progress bar for long-running dll

I have written a FORTRAN dll to perform math operations on gigabytes of data. This can take hours, so I want the dll to signal progress to the Xojo mainline and Xojo to draw a progress bar.

Any suggestions?

Write a function that can track the progress ( via local status var etc ) in the fortran dll. Xojo call the function periodically to see progress? This might not be superefficient but will save you trouble on cross languages/ modules delegates and callbacks.

1 Like

Thanks, Hanif. That is useful. My thinking was that the dll would have to raise an event in Xojo. Your approach is much easier with a Xojo timer.

If a xojo progressbar doesn’t function, then this idea won’t either. The dll will need to callback to a function in xojo to report progress. The xojo function needs to be global or a shared method. A regular method on the window will not work.

1 Like

Tim, the .dll will be called from a Xojo thread. Are you saying that the .dll will not allow other Xojo threads any time-slots?

Unless the dll is specifically programmed to launch a process on another core, that is correct. It will block the Xojo thread, and therefore the entire app, until it returns. All xojo programs are single core, and any dll they call runs on that core.

maybe you can create a xojo command line app with your FORTRAN dll
and use standard output to read from shell call in a xojo ui app?

2 Likes

Thanks Markus. Great idea! Simple for Fortran to open a temporary work file, write current status to it, then close the file. Xojo reads the work file based on a timer.

Thanks, Tim - then it’s better to use the method of Markus.

The motivation for the dll was so that Xojo and Fortran could share gigabyes of work memory. With the command line app, the work memory will need to be written to disk by Xojo and read by Fortran. Similarly when Fortran completes. Any suggestions?

BTW, the motivation for the Xojo front-end is the UTF-compatible GUI, which Fortran does not support.

instead of this file i would try StandardOutputStream and read via
https://documentation.xojo.com/api/os/shell.html#shell-readall

Hi MarkusR, yes, thank you. That work’s for me! Here’s my test code in case someone else needs it.

Var s As shell
s = New shell
s.ExecuteMode = shell.executemodes.Asynchronous
' Console1.exe is a console app that writes sequential numbers
' to stdout in a time-delayed one-second loop
s.execute("C:\....\Console1.exe")
Break ' so that I can single step the next part
While s<>Nil 
  ' watch "output" in the Variables window
  ' it shows the list of numbers since the previous ReadAll
  ' These can be used to construct a standard Xojo progress bar
  Var output As String = s.ReadAll
Wend
Return
1 Like

in case someone else needs it

if this shell object it not stored in function scope it can be read by timer and without while wend.

Don’t poll Shells like this. Instead, create a subclass of Shell and use its DataAvailable event to inspect the shell command’s output.

2 Likes