Mr-Markus / ZigbeeNet

A .NET Standard library for working with ZigBee
Eclipse Public License 1.0
131 stars 47 forks source link

Use Task.Run() instead of Start() #89

Closed nicolaiw closed 4 years ago

nicolaiw commented 4 years ago

https://github.com/Mr-Markus/ZigbeeNet/blob/065fc7f402efd82a3333155edc756214caade1a3/libraries/ZigBeeNet/Database/ZigBeeNetworkDatabaseManager.cs#L164

see: https://stackoverflow.com/questions/29693362/regarding-usage-of-task-start-task-run-and-task-factory-startnew

spudwebb commented 4 years ago

Task.Run does not allow to pass TaskCreationOptions.LongRunning, so shouldn't we use Task.Factory.StartNew instead?

also there is the same problem here: https://github.com/Mr-Markus/ZigbeeNet/blob/065fc7f402efd82a3333155edc756214caade1a3/libraries/ZigBeeNet.Transport.SerialPort/ZigBeeSerialPort.cs#L99-L102

nicolaiw commented 4 years ago

ur right .. this should be changed as well .. I would agree .. StartNew() would be an option .. another topic is the call to Task.Result in this project .. this should be avoided ..

spudwebb commented 4 years ago

fixed in PR #90

Mr-Markus commented 4 years ago

Good improvement