Hi, Until recently, I have been able to stay away from threads. I assumed the event handlers in the GUI would be threaded enough and all was good in the world. Alas, my Gtk# application needs worker threads to be responsive.
I use the anonymous delegates heavily though probably still not enough. Gtk.Application.Invoke (delegate { --code to update GUI here-- }); For the most part it works great!. I would like to share something I learned. Event handlers need to be cleaned up. It is always a good idea to cleanup after one's self, but with a great Garbage Collector one can easily forget. If you have some code that adds an event handler in a set property, you need to find a way to remove the event if it was previously added. This probably seems obvious to all the senior C# gurus out there (please don't give me lessons in style), but I was very impressed to resolve this problem. public SomeProp SomeProp { set { //DO NOT forget to remove the event previously added if (null != someProp) { someProp.ResultsUpdated -= new EventHandler(SomePropEventHandler); } someProp = value; someProp.ResultsUpdated += new EventHandler(SomePropEventHandler); OnChanged(); } } Is there any way to have Gendarme verify that the events get cleaned up somewhere? Good manners with regard to resources in my mind should be something that could be analyzed to produce some kind of warning. I still have some thread/resource issues and it is extremely difficult to hunt down these bugs. I am unable to close my application after I start my workers even if they run their course and finish. I probably have more issues of the same type. Thanks, Vlad (a humble Gtk# noob) _______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list