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#
  4. Problems of losing handle to stdcall-api from C#-DLL

Problems of losing handle to stdcall-api from C#-DLL

Scheduled Pinned Locked Moved C#
helpcsharphardwarejsonquestion
1 Posts 1 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.
  • J Offline
    J Offline
    J Holzer
    wrote on last edited by
    #1

    Hi! I have a stdcall-DLL, that works as an API and offers me connection to a hardware-device using "open"/"close"-methodes, as well a "read"/"write"-methodes for accessing the device. These API-calls are wrapped by a C#-DLL, that encapsules the calls an offers some methods i need to use in my application. The API´s "open"-method delivers a handle, that is used with the other functions to access the device. This handle is stored in a private class-member for further use with the read-methodes. My application/wrapper-DLL opens the connection, then reads something from the device everytime an external signal arrives at my software. When starting my app everything works fine for some hours or days, until nothing can be read from the DLL and an error occurs ssaying "invalid handle". When trying to re-connect the device (API-calls "close" and "connect") the API tells me that the connection is already open and i cannot connect to the device. After restarting my software everything works fine again. Because of this behaviour i changed the operation of my software: Now the device is re-connected everytime i finished a read-operation. This is because i thought that maybe the API might have a problem with a long-term connection. Unfortunately i get the same problem again: After some hours/days i get an "invalid handle" again. As the application should run 24/7 i need a way to stabilize this connection to the device. Does anyone have an idea, where my problem might be? Thanx a lot Greetings JH

    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