开发者

Receive Event Notification Broad-casted from Fortran in Managed Code

开发者 https://www.devze.com 2022-12-27 15:51 出处:网络
I have a fortran (unmanaged code) dll as the calculation engine, and a C# form as the GUI. Now, the calculation in fortran is long, so in order not to bore the users, I decided to use Asynch command

I have a fortran (unmanaged code) dll as the calculation engine, and a C# form as the GUI.

Now, the calculation in fortran is long, so in order not to bore the users, I decided to use Asynch command to create a progress bar. The fortran dll would be responsible for putting messa开发者_运维问答ges in the progress bar as the calculation proceeds.

Any idea how this can be done?


You have to implement anoter function in Fortran dll that reports progress in numbers. For instance: "GetCalculationProgress" that returns two integers (current iteration and total number of iterations). You call that function periodically in another thread in your C# app and read those values. In Fortran you might have to use global variables to track those.

Besides, Here is a link that explains callback method:

http://xtechnotes.blogspot.com/2008/07/callback-to-c-from-unmanaged-fortran.html


Single responsibility: The UI shoul be responsible for display of the progress information, be it a progress bar or other visual effect. The Fortran should not be aware of how the information is displayed, rather it just emits "events" saying thinggs such "just started", "55%", "almost done" and "whoops that didn't work.

How do the events get passed? You probably need some kind of "buffering" tecnhology, perhaps using (named) pipes, or a message queue technology. Fortran can use C libraries so I guess that once you select a communication technology if that's not supported by Fortran directly you can start by writing a bit of C and then get at that from Fortran.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号