Default parameter for CancellationToken

前端 未结 6 2084
猫巷女王i
猫巷女王i 2021-02-06 20:05

I have some async code that I would like to add a CancellationToken to. However, there are many implementations where this is not needed so I would like to have a d

6条回答
  •  深忆病人
    2021-02-06 20:32

    Newer versions of C# allow for a simplified syntax for the default(CancellationToken) version. E.g.:

    Task DoStuff(...., CancellationToken ct = default)
    

提交回复
热议问题