The Callback classes have been refactored to adopt modern C# practices. The changes made include:
Replace delegate CallbackFunction with the built-in Action delegate for the OnRun event handlers in both Callback and Callback<TParameter> classes.
Change the Run method in the Callback<TParameter> class to check if marshalling from nint to TParameter is successful, throwing an ArgumentException if it isn't.
Modify properties Id and IsServer to use the init keyword to make them immutable after they're set.
The updated code aligns with current best practices and provides some error handling.
The
Callback
classes have been refactored to adopt modern C# practices. The changes made include:Replace delegate
CallbackFunction
with the built-inAction
delegate for theOnRun
event handlers in bothCallback
andCallback<TParameter>
classes.Change the
Run
method in theCallback<TParameter>
class to check if marshalling fromnint
toTParameter
is successful, throwing anArgumentException
if it isn't.Modify properties
Id
andIsServer
to use theinit
keyword to make them immutable after they're set.The updated code aligns with current best practices and provides some error handling.