Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,

I am working with WPF (Windows Presentation Foundation). Newbie :)

The problem is I want to CONTINUOUSLY read from a log file which is being written by an other program at same time and update the textbox in the form. So, one program is continuously writing and other is continuously reading from same file.

I need suggestions what are the possible solutions to implement it.

One solution I can think of is to start another thread which opens the file in readonly mode.

Is it possible to bind text box to text file? So, that it is updated automatically.

Any suggestions will be great!

Thanks
BR
Posted

Have the program that's writing to the file open it with write exclusive, and have the other program run a FileSystemWatcher on the file. When it detects that the file has been written to, it can then read from the file.

Yes, threading will be required so that you don't lock up the UI on the reading program.
 
Share this answer
 
Comments
[no name] 11-Dec-10 19:28pm    
Damn silly of me, I completely forgot about FileSystemWatcher. Thanks for the reminder.
You may want to look at this ReaderWriterLock[^] however the difficulty may come if the the other application has an exclusive lock on the file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900