Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Synclock a part of a 2 dimensional array?

Posted on 2006-06-12
5
Medium Priority
?
264 Views
Last Modified: 2010-04-23
How can I synclock a part of a 2 dimensional array?

Dim objThing(1000,1000) as String

Synclock objThing(800,800)

End Synclock

This way I can access only one part while the rest of the object can be accessed by other threads at the same time?

0
Comment
Question by:Hepen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 16883651
Yes, by this way you can lock one array member.
0
 

Author Comment

by:Hepen
ID: 16883652
i tried but it wouldn't let me ... can u show me the code
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16883658
However, this doesn't prevent other thread from working with whole objThing array, like:
objThing = Nothing

If your code doesn't do this, it is OK.
0
 

Author Comment

by:Hepen
ID: 16883661
Let me give u points for this question i'm gonna ask another one i made a small mistake.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16883671
Oops, there is restriction:
You cannot change the value of lockobject while executing a SyncLock block. The mechanism requires that the lock object remain unchanged.

Since string is immutable object, this code will not work. This can work with other classes, with one additional restruction: lockobject cannot be Nothing. For example:

Dim objThing(1000,1000) as MyClass
' initialize all objThing members to New MyClass

Synclock objThing(800,800)
  ' ...
End Synclock

So, this way can be used with initialized array of mutable instances. In your case this will not work, you need to lock the whole array.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question