async private void ButtonGetDateClicked(object sender, EventArgs a)
{
- string currentDate = await view.getCurrentDate();
- if (currentDate != null)
+ try {
+ string currentDate = await view.getCurrentDate();
+ if (currentDate != null)
+ {
+ this.RemoteDate.Buffer.Text = currentDate;
+ }
+ }
+ catch (Exception e)
{
- this.RemoteDate.Buffer.Text = currentDate;
+ Console.WriteLine("ButtonGetDateClicked. Message: {0} Stacktrace: {1}", e.Message, e.StackTrace);
}
}
}
async public Task<TResult> callRemoteService<TResult>(string uri, string method)
{
- TResult result = default(TResult);
var postData = new POST();
postData.id = "2114567586433855105";
postData.jsonrpc = "2.0";
}
};
- try {
- string data = JsonConvert.SerializeObject(postData, jsonSettings);
- HttpContent content = new StringContent(data, System.Text.Encoding.UTF8, "application/json-rpc");
+ string data = JsonConvert.SerializeObject(postData, jsonSettings);
+ HttpContent content = new StringContent(data, System.Text.Encoding.UTF8, "application/json-rpc");
+
+ HttpResponseMessage response = await this.issueCall(uri, content);
- HttpResponseMessage response = await this.issueCall(uri, content);
+ TResult result = default(TResult);
- if (response.StatusCode == HttpStatusCode.OK) {
- Task<byte[]> responseBytes = response.Content.ReadAsByteArrayAsync();
- string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result);
+ if (response.StatusCode == HttpStatusCode.OK) {
+ Task<byte[]> responseBytes = response.Content.ReadAsByteArrayAsync();
+ string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result);
- POSTResult<TResult> postResult = JsonConvert.DeserializeObject<POSTResult<TResult>>(responseString, jsonSettings);
- result = postResult.result;
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("callRemoteService exception. Message: {0} Stacktrace: {1} ", e.Message, e.StackTrace);
+ POSTResult<TResult> postResult = JsonConvert.DeserializeObject<POSTResult<TResult>>(responseString, jsonSettings);
+ result = postResult.result;
}
return result;