-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to cancel service.SearchStreamAsync() ? #360
Comments
Hi @sommmen right now you have to write a longer version like this: string query = "YOUR_QUERY_HERE";
var request = new SearchGoogleAdsStreamRequest()
{
CustomerId = customerId.ToString(),
Query = query,
};
GoogleAdsServiceClient googleAdsService = client.GetService(
Services.V10.GoogleAdsService);
SearchStreamStream searchStream = googleAdsService.SearchStream(request);
var responseStream = searchStream.GetResponseStream();
while (await responseStream.MoveNextAsync(CancellationToken.None))
{
SearchGoogleAdsStreamResponse resp = responseStream.Current;
foreach (GoogleAdsRow row in resp.Results)
{
// Process the row.
}
} If I added an optional |
Yeah generally any After browsing a bit it looks like the following works as well: _ = await service
.SearchStreamAsync(customerId, query, resp =>
{
results.AddRange(resp.Results);
}, SummaryRowSettingEnum.Types.SummaryRowSetting.NoSummaryRow, CallSettings.FromCancellationToken(cancellationToken)); I'm doing the same for var customers = customerService
.ListAccessibleCustomers(new ListAccessibleCustomersRequest(), CallSettings.FromCancellationToken(cancellationToken))
.ResourceNames
.ToArray<string>(); Anyhow adding a cancellation token to the async method would be great and would be what .net devs expect. If what i'm doing right now is the way to go that is acceptable as well - but i'd love a small mention in the docs in that case - because i just found this by some trial and error with the code so it was hard to find. |
…set a cancellationtoken on the callsettings instead. Fixes #360
Thanks buddy! |
…set a cancellationtoken on the callsettings instead. Fixes googleads/google-ads-dotnet#360 (#369)
What is your question?
Hello - i'd like for my app to be able to shutdown gracefully and for that i need to be able to cancel any outgoing requests - it seems like the method:
Does not have an overload for
cancellationToken
. I could not find anything in the docs - how can i cancel any outgoing requests?The text was updated successfully, but these errors were encountered: