jchristn / SuperSimpleTcp

Simple wrapper for TCP client and server in C# with SSL support
MIT License
459 stars 95 forks source link

SimpleTcpClient: Can DataReceived be async? #209

Closed woha closed 4 months ago

woha commented 4 months ago

I want to await an async call inside my DataReceived method and want to make DataReceived itself async.

In the change notes under "New in v3.0.x", I found "Configurable sync vs async for firing DataReceived events (thank you @TheNybbler)", but I was unable to find further documentation or samples.

Is there a way to await async calls in DataReceived?

jchristn commented 4 months ago

The Settings.UseAsyncDataReceivedEvents, when set to true, simply fires the event handler as an unawaited task. I'm not aware of a widely agreed-upon standard for async event handlers.