Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

This PR addresses issue #9 by modernizing the UdpReceiver implementation to use Tasks instead of direct Thread management.

Changes made:

  • Replaced Thread with Task: Changed from new Thread(Receiver) to Task.Run(() => Receiver(cancellationToken))
  • Added proper cancellation: Implemented CancellationTokenSource for graceful shutdown
  • Improved resource management: Added proper disposal of CancellationTokenSource
  • Enhanced termination handling: Uses cancellation tokens instead of just boolean flags
  • Maintained API compatibility: All public methods remain unchanged

Benefits:

  • Better resource utilization: Tasks use ThreadPool threads more efficiently than dedicated threads
  • Improved cancellation: Proper cancellation token support for responsive shutdown
  • Modern .NET practices: Follows current async/await patterns and Task-based programming
  • Better exception handling: Cleaner handling of cancellation exceptions

Testing:

  • ✅ All existing UdpReceiver tests pass
  • ✅ Build succeeds with no new warnings related to the changes
  • ✅ Maintains backward compatibility

🤖 Generated with Claude Code


Resolves #9

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #9
@konard konard self-assigned this Sep 14, 2025
- Replace direct Thread usage with Task.Run() and ThreadPool
- Add proper cancellation token support for graceful shutdown
- Maintain existing API compatibility while modernizing implementation
- Improve resource management with proper CancellationTokenSource disposal

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Try ThreadPool / Tasks Replace Thread with Task-based approach in UdpReceiver Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 10:24
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.

Try ThreadPool / Tasks

2 participants