Idea for reading ad writing at the same time
-
-
hi, someone has an idea for object the i can write to it strings (with the first thread) and read from this object at th same time(with the second thread)? it will be very helful if this object will can convert itself to StreamReader. thank you.
-
why would you need to do that?
My opinion is... If someone has already posted an answer, dont post the SAME answer
now, i can analize a file (file.log) convert it to StreamReader and analize it with my object Parser(StreamReader sr). (i am using there sr.readline() etc.) now i want to receive the same information from port. i want to receive information from port232 (strings) and to save them (somewhere),and to analize them with th same object Parser(StreamReader sr) on a real time(2 threads- one for writing information from port to StreamReader(possible???) and another thread for reading the inforamtion by using Parser). thank you.
-
now, i can analize a file (file.log) convert it to StreamReader and analize it with my object Parser(StreamReader sr). (i am using there sr.readline() etc.) now i want to receive the same information from port. i want to receive information from port232 (strings) and to save them (somewhere),and to analize them with th same object Parser(StreamReader sr) on a real time(2 threads- one for writing information from port to StreamReader(possible???) and another thread for reading the inforamtion by using Parser). thank you.
ok well i think the problem you will have is writing to a file that is open for reading. So you could either close the file after the write and then read, somehow you will have to decide which process to do, or alteratively you could pass the string value to the parsing thread and write it to the log file, rather than reading from the file.
My opinion is... If someone has already posted an answer, dont post the SAME answer
-
ok well i think the problem you will have is writing to a file that is open for reading. So you could either close the file after the write and then read, somehow you will have to decide which process to do, or alteratively you could pass the string value to the parsing thread and write it to the log file, rather than reading from the file.
My opinion is... If someone has already posted an answer, dont post the SAME answer
i thought about it but.. opening and closing the file a lot of times will not slow down the analizing time? maybe there is something like "virtual file" or another solution that will let update the real file every X seconds?(for backup). or this is the only way to solve this problem?
-
i thought about it but.. opening and closing the file a lot of times will not slow down the analizing time? maybe there is something like "virtual file" or another solution that will let update the real file every X seconds?(for backup). or this is the only way to solve this problem?
i think you should be opening and closing streams with each write anyway, you dont want to leave a stream open longer than needed. As i also suggested, i think the best way is to: Get string from port, Write it to the log file, then pass it to the parsing thread for whatever that needs to do
My opinion is... If someone has already posted an answer, dont post the SAME answer