I have a bit of code I'm working on at work that makes use of an HTTP endpoint to notify a legacy system of certain events. Because the network is not reliable, we have to handle the case when the network may be down. In this situation, it means to try again a few times, after which the processing request goes into an error queue, where it can be handled manually. So, I started out with something like this:
This calls the HTTP endpoint up to five times. If one of those times succeeds, it returns the result and stops trying. If it gets to the sixth time, it gives up.
Now, in my project, I have several of these types of calls to make. Much of the above code, namely the exception handling and flow control stuff, is common to all of them. So, using some functional .NET and an extension method, we can do this:
This will attempt to execute and return the value offunc
up to times
times, and give up after that. With this extension method, we can now put our endpoint-calling code in a Func<int>
and tell it to try to call the endpoint up to five times, like this:
Now, is this the best way to do this? Maybe; maybe not. It's just something I've been toying around with in my attempts to eliminate duplication of the aforementioned ugly flow control code. I'll have to walk around in these shoes for a while and see whether I like them.
17 comments:
awesome article,the content has very informative ideas, waiting for the next update...
javascript training in chennai
javascript training center in chennai
javascript classes in chennai
javascript training in anna nagar
javascript training in vadapalani
javascript training in chennai
core java training in chennai
Photoshop Classes in Chennai
Manual Testing Training in Chennai
Drupal Training in Chennai
The blog which you have shared is more creative... Waiting for your upcoming data...
Python Training in Chennai
Python course in Chennai
Python Training
Best Python Training Institute in Chennai
Python Training in Velachery
Python training in Adyar
Hadoop Training in Chennai
Software testing training in chennai
JAVA Training in Chennai
Really wonderful blog! Thanks for taking your valuable time to share this with us. Keep us updated with more such blogs.
AWS Training in Chennai
AWS Training
AWS Training institute in Chennai
DevOps Training in Chennai
Azure Training in Chennai
VMware Training in Chennai
AWS Training in Velachery
AWS Training in Tambaram
AWS Training in Tnagar
AWS Training in Anna nagar
Nice Blog...Thanks for sharing the article waiting for next update...
Artificial Intelligence Course in Chennai
best artificial intelligence training in chennai
C C++ Training in Chennai
javascript training in chennai
Html5 Training in Chennai
QTP Training in Chennai
Spring Training in Chennai
DOT NET Training in Chennai
Thanks for giving excellent Message. Waiting for the next article
DOT NET Training in Chennai
DOT NET Course Chennai
dot net institute in chennai
best dotnet training in chennai
dot net training in Porur
Html5 Training in Chennai
Spring Training in Chennai
Struts Training in Chennai
Wordpress Training in Chennai
SAS Training in Chennai
Are you trying to move in or out of Jind? or near rohtak Find the most famous, reputed and the very best of all Packers and Movers by simply calling or talking to Airavat Movers and Packers
good jobs guys
Ai & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
http://digitalweekday.com/
http://digitalweekday.com/
http://digitalweekday.com/
http://digitalweekday.com/
http://digitalweekday.com/
http://digitalweekday.com/
http://digitalweekday.com/
http://digitalweekday.com/
no deposit bonus forex 2021 - takipçi satın al - takipçi satın al - takipçi satın al - tiktok takipçi satın al - instagram beğeni satın al - instagram beğeni satın al - google haritalara yer ekleme - btcturk - tiktok izlenme satın al - sms onay - izlenme-satin-al.com/youtube - google haritalara yer ekleme - no deposit bonus forex 2021 - tiktok jeton hilesi - tiktok beğeni satın al - binance - takipçi satın al - uc satın al - finanspedia.com - sms onay - sms onay - tiktok takipçi satın al - tiktok beğeni satın al - twitter takipçi satın al - trend topic satın al - youtube abone satın al - instagram beğeni satın al - tiktok beğeni satın al - twitter takipçi satın al - trend topic satın al - youtube abone satın al - instagram beğeni satın al - tiktok takipçi satın al - tiktok beğeni satın al - twitter takipçi satın al - trend topic satın al - youtube abone satın al - instagram beğeni satın al - perde modelleri - instagram takipçi satın al - instagram takipçi satın al
marsbahis
betboo
sultanbet
marsbahis
betboo
sultanbet
I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. marsbahis
trendbet
galabet
instagram beğeni satın al
yurtdışı kargo
seo fiyatları
saç ekimi
dedektör
fantazi iç giyim
sosyal medya yönetimi
farmasi üyelik
mobil ödeme bozdurma
bitcoin nasıl alınır
tiktok jeton hilesi
youtube abone satın al
gate io güvenilir mi
binance referans kimliği nedir
tiktok takipçi satın al
bitcoin nasıl alınır
mobil ödeme bozdurma
mobil ödeme bozdurma
perde modelleri
MOBİL ONAY
turkcell mobil ödeme bozdurma
nft nasıl alınır
Ankara Evden Eve Nakliyat
TRAFİK SİGORTASI
Dedektor
WEBSİTE KURMA
Ask Romanlari
Razer Crackers is on Facebook. Join Facebook to connect with Razer Crackers and others you may know. Facebook gives people the power to share. Razer Surround Pro Download
The program has powerful controller aptitudes which uphold blend, prepared capacity individuals, simple to-locate, the individual and irrelevant expense of proprietorship accompanied by snappy use. Tally 9 With Crack Full Version Zip
Have I ever mentioned, how wonderful and comfortable your clothes are? No? Ups, sorry, they really are. Thanks! Happy birthday, sis, and hope your closet will always be full. Happy Birthday Sister Funny
Post a Comment