tags:

views:

24

answers:

2

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?

A: 

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.

djna
Thanks, you have an example on how to do this?
Ngu Soon Hui
+1  A: 

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

ssg
Thanks, you have an example for this?
Ngu Soon Hui
You don't need an example, just call that new method like you're calling the other calculation function in Fortran dll.
ssg
Take a look at this too: http://xtechnotes.blogspot.com/2008/07/callback-to-c-from-unmanaged-fortran.html
ssg
Your link is a nice one, can you put it in your main answer so that I can reward you appropriately.
Ngu Soon Hui
I did...............
ssg