接收托管代码中 Fortran 广播的事件通知
我有一个 fortran(非托管代码)dll 作为计算引擎,还有一个 C# 表单作为 GUI。
现在,fortran中的计算很长,所以为了不让用户感到厌烦,我决定使用Asynch命令来创建进度条。 Fortran DLL 将负责在计算进行时将消息放入进度栏中。
知道如何做到这一点吗?
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 messages in the progress bar as the calculation proceeds.
Any idea how this can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在 Fortran dll 中实现另一个函数来报告数字进度。例如:“GetCalculationProgress”返回两个整数(当前迭代和迭代总数)。您可以在 C# 应用程序的另一个线程中定期调用该函数并读取这些值。在 Fortran 中,您可能必须使用全局变量来跟踪这些变量。
此外,这里有一个解释回调方法的链接:
http://xtechnotes.blogspot.com/2008/07/callback-to-c-from-unmanagement-fortran.html
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
单一责任:UI 应该负责显示进度信息,无论是进度条还是其他视觉效果。 Fortran 不应该知道信息是如何显示的,而它只是发出“事件”,说诸如“刚刚开始”、“55%”、“几乎完成”和“哎呀,不起作用。
事件是如何发生的”通过了吗?您可能需要某种“缓冲”技术,也许使用(命名)管道,或者 Fortran 可以使用 C 库,所以我想一旦您选择了一种通信技术,如果 Fortran 不直接支持您。可以从编写一些 C 语言开始,然后从 Fortran 中获得它。
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.