For example, if my library has this method :
int LongOperation();
now i would like to support cancellation, but not force it on the user, and i would like to avoid creating a ton of overloads for every method
1) would defining this method as
int LongOperation(CanellationToken cancellationToken = default(CanellationToken));
be good practice?
2) i would like to support Async (TPL) and Synchronous support, but still allow it to be cancelled regardless.
would definition these methods be good practice ? :
int LongOperation(CanellationToken cancellationToken = default(CanellationToken));
Task<int> LongOperationAsync(CanellationToken cancellationToken = default(CanellationToken));
Any opinions / feedback would be appreciated.
Aucun commentaire:
Enregistrer un commentaire