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
  • Hi!

    Thanks for the reply!

    My one loop-function only opens it once (in mode 16 at the moment, 0 didn´t work either) and keeps it open during scan and sleep.
    This works fine, but when another function opens the same device the loop-function crashes, when debugging I get error 269 - Bad handle specified, and the loop-function crashes.

    So I debugged it a bit more and found that my loop-function opens the device, and gets a handle number of 26.
    With that function running and with that handle thus open, I start another function that opens the same device, and gets the same handle number of 26! So when that function is finished it closes the handle and thus causes the loop-function to crash since the handle isn´t open anymore. Naturally.

    So the question is then, how do I get it to open it with a unique handle? Open in mode 1 - exclusive doesn´t seem right since that will cause other DevOpens to fail.
    Maybe open it on startup and use the same handle in all functions? But this is to be run on a redundant server with connected clients, all using these functions. Can the handle be shared so globally?
Reply
  • Hi!

    Thanks for the reply!

    My one loop-function only opens it once (in mode 16 at the moment, 0 didn´t work either) and keeps it open during scan and sleep.
    This works fine, but when another function opens the same device the loop-function crashes, when debugging I get error 269 - Bad handle specified, and the loop-function crashes.

    So I debugged it a bit more and found that my loop-function opens the device, and gets a handle number of 26.
    With that function running and with that handle thus open, I start another function that opens the same device, and gets the same handle number of 26! So when that function is finished it closes the handle and thus causes the loop-function to crash since the handle isn´t open anymore. Naturally.

    So the question is then, how do I get it to open it with a unique handle? Open in mode 1 - exclusive doesn´t seem right since that will cause other DevOpens to fail.
    Maybe open it on startup and use the same handle in all functions? But this is to be run on a redundant server with connected clients, all using these functions. Can the handle be shared so globally?
Children
No Data