Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
579 stars 96 forks source link

[BUG] The current state of DiscordRpcClient.Deinitialize #100

Open LeagueRaINi opened 3 years ago

LeagueRaINi commented 3 years ago

What actually is the purpose of Deinitialize ? I'm working on a small utility tool that uses this library and i wanted to be able to easily activate/deactivate the rpc client which i thought was the purpose of Deinitialize but after calling it u cant do anything cause the namedPipe gets disposed and the thread is not being nulled which makes calling Initialize again impossible

Lachee commented 3 years ago

Is this still the case, are you unable to recall Initialize after calling Deinitialize. If so, please reopen this issue as that is a bug. The purpose of deinitialize was to clear the RPC connection but retain all the configuration for it, so you could later call Initialize again

LeagueRaINi commented 3 years ago

This seems still be the case on the main branch here, i temp fixed it on my fork for now What i did was change the 2 main reasons Initialize cannot be called again

i also invoked the OnClose event in Deinitialize to know when the shutdown completed cause it seemed weird that there is no event indicating that and i didnt wanna check IsInitialized in a loop

if (OnClose != null)
    OnClose.Invoke(this, new CloseMessage("Manual shutdown request"));

Also sry for opening 2 issues, couldnt remove the label here and wasnt sure if its a bug so i closed & reopened another one without a label