Skip to content

Instantly share code, notes, and snippets.

@russcam
Created December 28, 2016 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russcam/8812c1c8bdeccdc034e5dbbd8a07450d to your computer and use it in GitHub Desktop.
Save russcam/8812c1c8bdeccdc034e5dbbd8a07450d to your computer and use it in GitHub Desktop.
Cancellation for async methods in NEST 2.x
void Main()
{
var client = new ElasticClient();
var cancellationTokenSource = new CancellationTokenSource();
client.Search<Document>(s => s
.Query(q => q
.MatchAll()
)
.RequestConfiguration(r => r
.CancellationToken(cancellationTokenSource.Token)
)
);
}
public class Document
{
public string Field { get; set;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment