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

Migrate from using Threads to using Tasks for receiving and sending data #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AlexanderNorup
Copy link

This PR changes the background tasks from using threads to instead use tasks.

The reason for this change is that using Threads using ThreadStart will keep the thread reserved for that background job, even though that job might just wait for input. That means no-one else can use that thread which might lead to depleting the thread pool if you had multiple VNC connections open. It thus isn't very scalable.
The second benefit of not using threads is that exceptions can't be handled in threads at all, which leads to unhandleable problems like in #25.

The only issue with my implementation is that any exceptions thrown get silently eaten until the Task is awaited (which in my case happens when StopSendLoopAsync() is called). I don't really know of a good solution for this, however feedback is welcome. It might also be small enough to be considered a "won't fix™".

If you have any questions about my implementation, please reach out.

Closes #25

@MarcusWichelmann
Copy link
Owner

Very nice, thank you! Will have a look when I'm back from vacation.

paviad added a commit to paviad/MarcusW.VncClient that referenced this pull request Jul 26, 2024
paviad added a commit to paviad/MarcusW.VncClient that referenced this pull request Jul 26, 2024
paviad added a commit to paviad/MarcusW.VncClient that referenced this pull request Jul 26, 2024
paviad added a commit to paviad/MarcusW.VncClient that referenced this pull request Jul 26, 2024
paviad added a commit to paviad/MarcusW.VncClient that referenced this pull request Jul 28, 2024
paviad added a commit to paviad/MarcusW.VncClient that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception Occurs When Executing CloseAsync() and Dispose() Method
2 participants