Main Site Documentation

BeginInvoke


#1

Hi All,

Starting a new G120 project and its been a while since I’ve done any multi-threaded programming. I have a new thread that I’m starting, and it has a couple of events I’m raising. In order for this to be thread-safe I assume I need to call BeginInvoke like I do in WPF but I’m not sure how to do it in .NETMF with lambda expressions without actually creating delegates. Is there an example I can look at of this?

Thanks,
Bob


#2

What do you have so far?


#3

@ rocketbob - BeginInvoke should only be used with a WPF application to serialize GUI operations. For all other thread-safe operations a Monitor object or use of the lock keyword should be used.


#4

Here are two good articles on events and multi-threading:

http://csharpindepth.com/Articles/Chapter2/Events.aspx

http://www.codeproject.com/Articles/20550/C-Event-Implementation-Fundamentals-Best-Practices


#5

A realy good tutorial :
http://www.albahari.com/threading/threading.pdf


#6

Thanks guys, good refresher for me. My UI is more or less akin to a single-page website, where there are not multiple forms but am showing and hiding things based on user input. I am simply drawing things with bitmaps and am not using WPF, just to keep things simple. So far even without BeginInvoke calls things are working fine with my event handlers.