Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Idea for reading ad writing at the same time

Idea for reading ad writing at the same time

Scheduled Pinned Locked Moved C#
question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Admin887
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • A Admin887

      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.

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      why would you need to do that?

      My opinion is... If someone has already posted an answer, dont post the SAME answer

      A 1 Reply Last reply
      0
      • M musefan

        why would you need to do that?

        My opinion is... If someone has already posted an answer, dont post the SAME answer

        A Offline
        A Offline
        Admin887
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • A Admin887

          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.

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • M musefan

            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

            A Offline
            A Offline
            Admin887
            wrote on last edited by
            #5

            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?

            M 1 Reply Last reply
            0
            • A Admin887

              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?

              M Offline
              M Offline
              musefan
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups