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

Exception Occurs When Executing CloseAsync() and Dispose() Method #25

Open
hungba6 opened this issue Apr 1, 2024 · 3 comments · May be fixed by #26
Open

Exception Occurs When Executing CloseAsync() and Dispose() Method #25

hungba6 opened this issue Apr 1, 2024 · 3 comments · May be fixed by #26

Comments

@hungba6
Copy link

hungba6 commented Apr 1, 2024

Based on the API documentation available at
https://vnc-client.marcusw.de/apidoc/api/MarcusW.VncClient.RfbConnection.html#methods,
I attempted to disconnect from the server using two methods bellow, however, both methods resulted in an exception being raised:

  • RfbConnection.CloseAsync()
    image

  • RfbConnection.Dispose().
    image

with:
RfbConnection = await _connectionManager.ConnectAsync(parameters, cancellationToken).ConfigureAwait(true);
(Source:

RfbConnection = await _connectionManager.ConnectAsync(parameters, cancellationToken).ConfigureAwait(true);
)

I'm uncertain whether my implementation is incorrect or if the two methods mentioned above are not fully implemented yet.

@MarcusWichelmann
Copy link
Owner

That an OperationCanceledException gets thrown may happen in this case. But if you catch it, it should be fine.

@AlexanderNorup
Copy link

AlexanderNorup commented Apr 5, 2024

That an OperationCanceledException gets thrown may happen in this case. But if you catch it, it should be fine.
@MarcusWichelmann

You can't just catch the exception, because you use ThreadStart to start the background thread. So the background thread will always just throw and break your entire application whenever you call CloseAsync().
You'd have need to catch the exception from the background-job code.

@MarcusWichelmann
Copy link
Owner

MarcusWichelmann commented Apr 5, 2024

@AlexanderNorup Oh, okay. I've not looked into that codebase for quite some time now. That's very unfortunate.

Then forget about what I said. 😅

I'm on vacation for a few weeks, but if someone wants to do a PR for that, I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants