Is it necessary to lock the I2C bus when performing a Write or WriteRead in 4.3?

I’ve seen some Gadgeteer module driver code (on other sites, by third parties) that performs a C# lock on the I2C bus returned by GTI.I2CBusFactory.Create whenever they do a Write or WriteRead operation. Is this necessary in 4.3 to keep multiple threads from accessing the bus, or is this taken care of for us down in the Write and WriteRead methods?


The best way to answer this question is to download the gadgeteer source and read the code.

@ Mike -

Based on my read of the Gadgeteer source files I2CBus.cs and NativeI2CBus.cs, it appears that all Write and WriteRead operations ultimately become calls to Execute in NativeI2CBus, and Execute performs a C# lock on the I2C bus object.

So, it appears to me that locking the bus in the Gadgeteer module driver is not necessary.