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 / C++ / MFC
  4. Two programs - Same file Instantaneous write and read.

Two programs - Same file Instantaneous write and read.

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 4 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.
  • P Offline
    P Offline
    Pecan204
    wrote on last edited by
    #1

    Can someone suggest a method to accomplish writing to a file and at that moment another program would read that same data for its use. The program is writing a line of floats to just generate data while the other program needs to read and process it. Using two seperate executables and an ascii file led to apparent file locking issues. Thanks for any suggestions. Ken

    M J D 3 Replies Last reply
    0
    • P Pecan204

      Can someone suggest a method to accomplish writing to a file and at that moment another program would read that same data for its use. The program is writing a line of floats to just generate data while the other program needs to read and process it. Using two seperate executables and an ascii file led to apparent file locking issues. Thanks for any suggestions. Ken

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      A file isn't the most reliable way to transfer data between apps. From your description, a socket would be a better way. And in any event, you'd still need some IPC to let the second app know that there's data to be read --Mike--    THERE IS NO     THERE IS NO    BUT THERE IS MAGIC PIXIE DUST  BUSINESS GENIE  CODE PROJECT Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

      1 Reply Last reply
      0
      • P Pecan204

        Can someone suggest a method to accomplish writing to a file and at that moment another program would read that same data for its use. The program is writing a line of floats to just generate data while the other program needs to read and process it. Using two seperate executables and an ascii file led to apparent file locking issues. Thanks for any suggestions. Ken

        J Offline
        J Offline
        John M Drescher
        wrote on last edited by
        #3

        You can do this with a memory mapped file and a named event. Create a named event and open it in both applications. Set it in one thread to signal that the other can read the data. When the data is read reset the event. http://www.codeproject.com/win32/cmemmap.asp[^] John

        P 1 Reply Last reply
        0
        • J John M Drescher

          You can do this with a memory mapped file and a named event. Create a named event and open it in both applications. Set it in one thread to signal that the other can read the data. When the data is read reset the event. http://www.codeproject.com/win32/cmemmap.asp[^] John

          P Offline
          P Offline
          Pecan204
          wrote on last edited by
          #4

          Thanks for the comments and links. Ken

          1 Reply Last reply
          0
          • P Pecan204

            Can someone suggest a method to accomplish writing to a file and at that moment another program would read that same data for its use. The program is writing a line of floats to just generate data while the other program needs to read and process it. Using two seperate executables and an ascii file led to apparent file locking issues. Thanks for any suggestions. Ken

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Use an “event” — a synchronization object that allows one thread to notify another that an event has occurred. Events are useful when a thread needs to know when to perform its task. For example, a thread that copies data to a data archive would need to be notified when new data is available. Look for CreateEvent(), SetEvent(), WaitForSingleObject(), etc.

            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