C
C#12mo ago
Sunwurp

C# Exit question

hello friends, I am developing a project in c# and when it is closed from the task manager, I cannot get my session module to exit because it exits urgently. I want to run my sessionend void in unexpected situations, but I have no idea how to do it.
9 Replies
canton7
canton712mo ago
If someone does "End task" from task manager, or powers off their computer, there's nothing you can do: your application will simply stop. You need to design you application to cope with this possibility.
Chiyoko_S
Chiyoko_S12mo ago
the 'end task' thing exists purely to solve cases where your application stops responding even to the shutdown request if your 'sessionend' function gets stuck and never returns, the program would never be able to exit the 'end task' / taskkill /f is there to solve exactly that purpose what is this 'session module'? why do you need to clean it up before exit? what kind of things are you cleaning up? what kind of application is this?
Sunwurp
SunwurpOP12mo ago
I am developing a launcher for a game, when the player logs in, I activate the session from the api and when he logs out, I want to close it back. If he closes it from the task manager, it will still appear online because the session remains open.
Chiyoko_S
Chiyoko_S12mo ago
from the client, periodically send some sort of heartbeat to the server; on the server, make the user offline if the heartbeat is lost for a certain amount of time?
Sunwurp
SunwurpOP12mo ago
Shouldn't I add a listener to the api for this? I think it will force me.
Chiyoko_S
Chiyoko_S12mo ago
errrrr not sure what you mean by that
Sunwurp
SunwurpOP12mo ago
I'm not sure how to do what you're saying.
Chiyoko_S
Chiyoko_S12mo ago
I suppose you're making the server app as well?
Sunwurp
SunwurpOP12mo ago
No, I don't, I have it custom-made.
Want results from more Discord servers?
Add your server