Solved

for 500pts <> File Locking and Unlocking. How its work?

Posted on 2006-10-21
1
134 Views
Last Modified: 2010-04-30
Hello Experts,
I have a structured file with only 2 records
File name : Gate.dts
Record Length: 3bytes
Structure :
Type Gate
    FileNo As Byte           '1
    atUse As Boolean       '2
End Type


this file open by process 1 (P#2)

Close #400: Open strCachePath & "Gate.dts" For Random Shared As #400 Len = 3

read some data
Get #400, 1, Gate

write some data
    Lock #400, 2
    Gate.atUse = True
    Put #400, 2, Gate
    Unlock #400, 2

This two records are regulary update by a second Process (P#2) say every 30 seconds
Similary P#1 need to  read and write data to Gate.dts
P#1 reading these records every 30 seconds or so

I'd like to give priority to P#2 if I can

now
1) when I reding data do I need to Lock and Unlock?
2) what will hapen if P#2 is writing to Gate.dts record 1 and P#1 want to read it same time? will it crash?

________________________________________
Aditional Information

in this scenario P#1 and P#2 are in different computers connected though network. P#1 act like a server.
some occations there could be more than one clients and can have multiple of P#2 process and Gate.dts.
Gate.dts located in client machines only

0
Comment
Question by:udanabanana
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 17783342
1) No. Locking is only relevant to writing.
2) No. You can read a locked record.
If you try to write to a locked record, you will can an error, not a crash.
The error is 70, Permission denied.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now