?
Solved

Synclock a part of a 2 dimensional array?

Posted on 2006-06-12
5
Medium Priority
?
263 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 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