Click here to Skip to main content
13,004,094 members (112,270 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Is it possible to modify "any" object in a thread which has not created it?
As we know that if the objects are UI controls, then attempting this would throw an error stating "Control accessed from a thread other than the thread it was created on"
Posted 1-Sep-10 2:04am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Yes, you just have to be aware of the rules and the process involved. If you google that error message, you'll find all kinds of examples about how to do it.
piushs 1-Sep-10 8:09am
Won't it throw similar kind of error? I am confused because objects other than UI controls dont have InvokeRequired property.
samqty 1-Sep-10 11:49am
you can access and update objects in different threads. it wouldn't throw an exception for other objects other than UI controls(its a validation imposed on such objects). the only thing would be you have to make sure there is no concurrent update on the object state because you will need to handle those scenarios to prevent data corruption.
There are a bunch of ways provided by .net to make your classes thread safe. the simplest one would be locking ...

hope this shed some light ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170627.1 | Last Updated 1 Sep 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100