Quantcast
Channel: Gemalto Sentinel Customer Discussions
Viewing all articles
Browse latest Browse all 1619

Re : What is the best way to check if a dongle is present?

$
0
0
Hello Parth,

thank you for your answer it helped me a lot. I now have a (I think) clean solution where only one session is active at a time. It is an endless loop and looks like this:

// Check if a dongle session is active
//
if(this.hasp.IsLoggedIn())
  // Check if the dongle is still connected
  //
  if (HaspStatus.StatusOk != this.CheckIfDongleStillPresent())
  {
    // The dongle is not there anymore, log out,
    // update the GUI and disable the license
    //
    this.hasp.Logout();
    this.SetDongleAbsent();
  }
}
else
{
  // Try to start a new session
  //
  if(HaspStatus.StatusOk == this.hasp.Login(vendorCode))
  {
    // Session was succesfully started, update the GUI,
    // and read the dongle Memory
    //
    this.SetDonglePresent();
    this.ReadMemoryFromDongle();
  }
  else
  {
    // No session could be started, update GUI and disable the license
    //
    this.SetDongleAbsent();
  }
}

I have a single hasp object and I simply try to read the dongle Memory in the function CheckIfDongleStillPresent() as you suggested. Although I did not notice any memory leak/overflow with the other method (calling Login() every time) I feel like this version is much better.

Thank you and best regards,

Pierre

Viewing all articles
Browse latest Browse all 1619

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>