Skip to content

Add CancellationToken explanation to SpeechToText docs#636

Merged
jfversluis merged 2 commits intomainfrom
copilot/add-cancellation-token-explanation
Mar 17, 2026
Merged

Add CancellationToken explanation to SpeechToText docs#636
jfversluis merged 2 commits intomainfrom
copilot/add-cancellation-token-explanation

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

The SpeechToText documentation uses cancellationToken without explaining what it is or how to obtain one. The dependency injection example also references an undefined cancellationToken variable.

  • Added a NOTE block under "Basic usage" explaining CancellationToken, CancellationTokenSource, and CancellationToken.None, with a link to Microsoft's threading docs (consistent with folder-picker.md)
  • Fixed the DI examplecancellationToken was an undefined variable. Now shows a CancellationTokenSource field with proper token creation:
private CancellationTokenSource? cancellationTokenSource;

public async void Listen(object sender, EventArgs args)
{
    cancellationTokenSource?.Cancel();
    cancellationTokenSource = new CancellationTokenSource();

    var isGranted = await speechToText.RequestPermissions(cancellationTokenSource.Token);
    // ...
}
Original prompt

This section details on the original issue you should resolve

<issue_title>The cancellationToken ... it's a mystery!</issue_title>
<issue_description>### Type of issue

Missing information

Description

The documentation is great, except it mentions a cancellationToken, but not where that comes from. It would be awesome if an explanation of that could be added to this

Page URL

https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/essentials/speech-to-text?tabs=android

Content source URL

https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/maui/essentials/speech-to-text.md

Document Version Independent Id

bd555d8e-ea79-876f-5108-fd6bb19d0d8a

Article author

@VladislavAntonyuk

Metadata

  • ID: bd555d8e-ea79-876f-5108-fd6bb19d0d8a
  • Service: dotnet-communitytoolkit
  • Sub-service: dotnet-maui-community-toolkit</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@learn-build-service-prod
Copy link

Learn Build status updates of commit 26bf09d:

⚠️ Validation status: warnings

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

… SpeechToText docs

Co-authored-by: jfversluis <939291+jfversluis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add explanation for cancellationToken in documentation Add CancellationToken explanation to SpeechToText docs Mar 17, 2026
Copilot AI requested a review from jfversluis March 17, 2026 08:41
@learn-build-service-prod
Copy link

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link

Learn Build status updates of commit a5ded68:

✅ Validation status: passed

File Status Preview URL Details
docs/maui/essentials/speech-to-text.md ✅Succeeded View

For more details, please refer to the build report.

@jfversluis
Copy link
Contributor

@copilot also mention that if you don't want to cancel it you can just use CancellationToken.None

Copy link
Contributor Author

Copilot AI commented Mar 17, 2026

@copilot also mention that if you don't want to cancel it you can just use CancellationToken.None

This is already covered in the NOTE block on line 63: "You can also use CancellationToken.None if you don't need to cancel the operation."

@jfversluis jfversluis marked this pull request as ready for review March 17, 2026 08:54
@jfversluis jfversluis merged commit 0b20e3f into main Mar 17, 2026
4 checks passed
@jfversluis jfversluis deleted the copilot/add-cancellation-token-explanation branch March 17, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The cancellationToken ... it's a mystery!

3 participants