I have a simple task: to read data from a server, if the server is unrecoverable (server down or bad network) Load data (potentially stale) from local disk cache.
How Java code looks like this is a simple pseudo representation:
try {// read from server //} (iOException ioe) {// Most likely That socket timeout read from the local disk exception} {{free I / O resource}} but implementing it does not appear in C # It seems that the WebClient , whenever there is no internet access on the host machine, then through the catch block, that situation So there is no way out and back into the local cache. I am aware of the async API of the WebClient and instead the fun callback series, but I consider it very strange and do not properly adhere to my design goals. Is there any way that I can do this in C # as easily as the Java Skeleton Code shown above? Thank you.
WebClient will be timeout, but only after 100
I would recommend that instead you use HttpWebRequest it has a fixed timeout asset.
View
No comments:
Post a Comment