Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LeagueRaINi opened this issue Oct 13, 2020 · 2 comments
Open

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

LeagueRaINi opened this issue Oct 13, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@LeagueRaINi
Copy link

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

@LeagueRaINi LeagueRaINi added the bug Something isn't working label Oct 13, 2020
@Lachee
Copy link
Owner

Lachee commented Oct 14, 2020

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
Copy link
Author

LeagueRaINi commented Oct 14, 2020

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

  • move the disposal of the named pipe from here into the Dispose() method

    if (namedPipe != null)
    namedPipe.Dispose();

  • call thread.join() to wait for the thread to finish & null it afterwards while also resetting aborted to false afterwards
    calling thread.join() has the slight negative effect that it locks the calling thread while the worker thread finishes its work

    //Terminate
    Logger.Trace("Updating Abort State...");
    aborting = true;
    queueUpdatedEvent.Set();

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

@LeagueRaINi LeagueRaINi reopened this Oct 14, 2020
@LeagueRaINi LeagueRaINi changed the title The current state of DiscordRpcClient.Deinitialize [BUG] The current state of DiscordRpcClient.Deinitialize Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants