|
-
Aug 9th, 2006, 10:32 PM
#1
Thread Starter
Frenzied Member
[2005] Getting and Setting a Property at the same time
I am wondering if any one knows what would happen, if I get a property at the same time it is being set. This application that I am working on we get this random error that happens anywhere from 2 - 48 hours of it running. The only error we get says that something crash in MsCorWks.dll (this is the .Net runtime). I think I have narrowed it down to one spot where it is possible that I am getting a property at the same time it is being set from a different thread.
So does anyone know what would happen if a property is set at the same time it it be retreived? Is there something built in that wouldn't allow this? Educated guesses welcome.
-
Aug 9th, 2006, 10:38 PM
#2
Re: [2005] Getting and Setting a Property at the same time
If the same data is being accessed by multiple threads simultaneously then the result is likely to be unpredictable, because you have no idea what state the first thread left things in before the second thread stepped in. Remember that each thread is being executed one line of MSIL at a time, not one line of VB at a time. Each of your lines of VB code may be many lines of IL code. The simple answer to this is to not let it happen by using proper thread synchronisation. SyncLock blocks are the easiest way to do this. If they don't cut it then the next step up is the Monitor class. I've only ever used SyncLock so I'm no expert but if you're having thread synchronisation issues then you should follow the Articles -> Advanced .NET link in my signature and read the Managed Threading section.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|