I guess it's a valid solution if you have no way to know when the PDF is available. The only problem is if for some unexpected reason it takes longer for the PDF to be available.
Maybe something like this could be useful?
varrequest=newHttpRequestMessage(HttpMethod.Head,url);varresponse=awaithttpClient.SendAsync(request,cancellationToken);//maybe limit the number of times this can be donewhile(response.StatusCode!=HttpStatusCode.OK){awaitTask.Delay(500,cancellationToken);response=awaithttpClient.SendAsync(request,cancellationToken);}
It's basically polling the PDF url to check when it's available.
On a side note, how's that CancellationTokenSource being used? You're using it to cancel the execution given some event?
I am new to Visual Studio, C#, .NET and Core. I also regularly work with legacy systems (iSeries) and PHP to communicate with it. Everyday, I ask myself: What did you learn today? This is the result.
I guess it's a valid solution if you have no way to know when the PDF is available. The only problem is if for some unexpected reason it takes longer for the PDF to be available.
Maybe something like this could be useful?
It's basically polling the PDF url to check when it's available.
On a side note, how's that CancellationTokenSource being used? You're using it to cancel the execution given some event?
not currently, i cleaned it up! thanks for spotting it!