threadsafe use of foreach

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have line of code that was originally written prior to .NET 2.0 as follows:

Foreach int i in Items.

The problem is it keeps throughing an exception about unsafe thread access.
I have read how to fix this using the check to InvokeRequired property but am
trying to figure how to apply it when using the foreach command since I have
to use a callback delegate to make a threadsafe access.
 
Never mind, I figured it out. Sorry to bother y'all. Looks like you call the
callback function/delegate from within the function that you need to run on
the thread in question, not before you run it. If that makes sense
 
Back
Top