"What's the easiest/best way to open a single file from multiple
applications "
You said that you were using multiple applications ... lock() only works
within the given appdomain (except in one odd circumstance which I highly
doubt you are using) .. It will not work between multiple processes ever as
the processes cannot possible have access to the same instance, remoting may
make you think you have access to the same object but in reality each app
domain has its own unique proxy (which is what would have to be locked on).
Cheers,
Greg
"UJ" <fr**@nowhere.comwrote in message
news:u4**************@TK2MSFTNGP04.phx.gbl...
What about using the lock keyword?
Do something like
lock this
{
OpenFile
WriteToFile
CloseFile
}
I'll be using the same object everywhere to do the actual writing....
J.
"UJ" <fr**@nowhere.comwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
>Every once in a while the mutex seemed to get lost by somebody so that
then nobody could access to the file.
Of course, since then I've cleaned up the code a lot so it may be fixed
now. I just have tried it.
I guess unless somebody else has a better idea, I'll put the mutex back
in and try it to see what would happen.
Thanks.
"Greg Young" <dr*******************@hotmail.comwrote in message
news:O4**************@TK2MSFTNGP05.phx.gbl...
>>If you want to keep the file open and they are all on the same machine
your initial thought of using a mutex seems correct ...
What were your problems with using a mutex to define a critical section
when writing to the file?
Cheers,
Greg
"UJ" <fr**@nowhere.comwrote in message
news:ua**************@TK2MSFTNGP05.phx.gbl...
What's the easiest/best way to open a single file from multiple
applications but so only one can read it at a time? I tried a mutex but
had problems. I noticed there is something called a ReaderWriter class
but it says it's best for reads.
I'll never be reading the file.....
TIA - Jeff.