Integration with Windows Forms

Jul 13, 2008 at 3:32 PM

Hello! and thanks for your great contribution. I'm really interested in your project since I'm learning concurrent programming and I always wanted to program elegantly. And your solution is really elegant :)

I used you MPAPI yesterday to simulate an airport, with the control tower and the airplanes. It was a console application and it went OK. But now my goal is to develop a small application that is able interact with Windows Forms. I thought of a Form that loads lots of images in order to add them to a ImageList as thumbnails. The image decoding of each picture is a lenghtly process and I want the user would be able to scroll throught the ListView that contains the thumbnails being added.

I think it would be really useful for tasks like this one, but I don't figure out how to do it and how to communicate a Node with the main thread. Please, give me(us) some example. 

Your help will be appreciated!


Jul 15, 2008 at 11:08 AM

This will be s short post without any concrete code since I am out of the country on vacation and I only have net access for a short period.

But what you wrote is one of the problems with this "disconnected" approach - there is no nice and clean way to couple the "ordinary" world (i.e. WinForms) with the MPAPI framework. What I have been thinking about is this (just an idea - I haven't tried it yet):

The worker that needs to communicate some kind of state to the winforms part of the application will have to expose one or more events. When this event is fired, the winforms part of the app will look inside the worker for the state. Remember to lock vital parts of the worker with a monitor or the lock-statement!
This should enable the winform controller to get state from the worker (or workers). Just remember that you cannot update a control from another thread. Use the Control.Invoke method on your form (for example)

I hope this clarifies the problem a bit. Otherwise please write to me again and I will address it as soon as possible.

Best regards.