Created
March 8, 2022 19:08
-
-
Save awswithdotnet/95da6922ba574794ff5439b6a2263097 to your computer and use it in GitHub Desktop.
sqs SQSMessageConsumer Complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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