Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Created March 8, 2022 19:08
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 awswithdotnet/95da6922ba574794ff5439b6a2263097 to your computer and use it in GitHub Desktop.
Save awswithdotnet/95da6922ba574794ff5439b6a2263097 to your computer and use it in GitHub Desktop.
sqs SQSMessageConsumer Complete
public async Task Listen()
{
_isPolling = true;
int i = 0;
try{
_source = new CancellationTokenSource();
_token = _source.Token;
while(_isPolling){
i++;
Console.Write(i + ": ");
await FetchFromQueue();
Thread.Sleep(_delay);
}
}
catch(TaskCanceledException ex){
Console.WriteLine("Application Terminated: " + ex.Message);
}
finally{
_source.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment