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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top