I have a background thread doing some work and a UI displaying the progress, and for various reasons, I'm not using a background worker; instead, a Timer
triggers updates to the UI.
I'm not using Invoke
calls at all. Instead, the background process writes to an array of 4 strings. This array is declared as an instance member of my main form.
Do I need to use locks to read this array from the UI thread? Is it fine to write to the array from the background thread and read from it from the UI one without any extra precautions?
EDIT: MSDN reads "The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock."
. Doesn't that mean that the lock will only prevent the same block of code from being run by two different threads?