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