private static void getAllMarkets( WebClient client, ref int count, ref Markets markets ) { try { markets = doWork( client, markets ); } catch( Exception e ) { Console.WriteLine( "Fetching data failed! (round " + count++ + ")" ); System.Threading.Thread.Sleep( 5000 ); markets = doWork( client, markets ); } }
private static Markets doWork( WebClient client, Markets markets ) { string result = client.DownloadString( "http://pubapi.cryptsy.com/api.php?method=marketdatav2" ); // Putting the JSON content of the URL into a string JObject obj = JObject.Parse( result ); SampleResponse1 response = JsonConvert.DeserializeObject<SampleResponse1>( result ); markets = response.Return.Markets; return markets; }