DevOpen, doesn´t open in shared mode?

Hi!

I have a device created, dBASE_DEV, that creates an DBF.

I then call this device from a number of functions primarily using DevOpen in mode 0. Defined as mode 0, not relying on default 0.
This works fine when one function at a time opens the device, does it's thing, and then closes it.

But when I then have a loop that opens the device and each 10seconds scans through it just reading what´s in it, not closing it while sleeping. That function crashes when an other function opens the device.

It sounds like mode 0, shared mode, wouldn´t cause this. But Iv´e also tried mode 16, read only. But I get the same result with it crashing.
If I debug I get the error for bad handle, so I guess that the mode isn't as shared as one would think..

Am I using the device wrong? Maybe it can´t be opened from more than one function at a time?

Parents
  • I tested this for a customer with a similar setup a number of years ago. They had multiple clients writing to the same log file on a file server. Each client would open the file, write a line, then quickly close the file. Normally they wouldn't conflict, but occasionally a client would get locked out and would refuse to open the file again until Windows was rebooted. Cicode error checking and device shared mode didn't help.

    The solution for them was, as Patrick said, to use MsgRPC() to send the messages to the Citect server, and then only the server wrote to the log file. An alternative, especially if you're writing a large amount of data or doing more than simple logging, would be to write to an SQL database--which is designed for multiple clients to connect simultaneously.
Reply
  • I tested this for a customer with a similar setup a number of years ago. They had multiple clients writing to the same log file on a file server. Each client would open the file, write a line, then quickly close the file. Normally they wouldn't conflict, but occasionally a client would get locked out and would refuse to open the file again until Windows was rebooted. Cicode error checking and device shared mode didn't help.

    The solution for them was, as Patrick said, to use MsgRPC() to send the messages to the Citect server, and then only the server wrote to the log file. An alternative, especially if you're writing a large amount of data or doing more than simple logging, would be to write to an SQL database--which is designed for multiple clients to connect simultaneously.
Children
No Data