c# - Event happens between read and clear operations, so, last data will lose -
I want to explain the question to the samples because it is an algorithmic issue.
Assume that a tool and client (2 sides) use a I think that when the customer opens the file for 10 seconds, the file tool (the event happens) or the reverse, when the occurrence of the device occurs then the file can be used by the client on this case Will data be lost? Assume that the client uses Customer is starting to work And every 10 seconds, I do this: Read the file and clear it. My question is, if the tool's event Line1 and Line2. , then what will happen? Can I lose past data? Because I can have an incident after reading and I will clear that read the data dispute. The same idea is the same algorithmic problem with my property, file is not You use the client to get a unique lock Can Tools If the file lock is locked before it is locked, it will be suspended until the lock is issued. The property is better to use: Before you read or write the property, call WaitForSingleObject and then release the lock MUTx. .txt file when the tool has an event, then it will be
.txt opens the file and logs in there. And for every 10 seconds, the client opens the file and checks it out, if there are any logs, remove them.
SomeTool and there is an event called
SomeEvent in the device. Therefore, when I start using that device,
SomeEvent may be at any time
public class client {private readonly some tools_steltall; Public Client () {// ... _someTool.eventSomeThing + = Something Happening Handler (client_evSomeThing); } Private Zero Client_evething (object sender, some data) {// event occurs and // open the file to this device, log in there. }}
Customer _client = New Customer ();
line 1 Var loginfile = _client.ReadLinesFromFile ("file path"); line 2. File. Write any text ("file path", string. Apt);
var iReadProperty = _client.SomeProperty; // What can happen here? If so, this event will give some value. // I'll delete it and lose the last value of someProperty how can I solve this issue? _client.SomeProperty = null; // I read it, and delete it. // Now I think iReadProperty is the last value, but it's not right. The last value is deleted
Comments
Post a Comment