private void AsyncCallback(IRestResponse response) { var doc = ProcessResponse(response); if (doc != null) { Successful?.Invoke(doc); } }
public void Execute() { for (var retry = 0; retry <= retries; retry++) { try { action(retry); Successful?.Invoke(this, new RetryArgs(attempt)); attempt = 0; return; } catch (Exception exception) { exceptionAction(exception, retry); attempt = retry; } Failed?.Invoke(this, new RetryArgs(attempt)); } }
private async Task <MTConnectAssets.Document> ProcessResponse(HttpResponseMessage response) { if (response != null) { if (!response.IsSuccessStatusCode) { ConnectionError?.Invoke(new Exception(response.ReasonPhrase)); } else if (response.Content != null) { string xml = await response.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(xml)) { // Process MTConnectAssets Document var doc = MTConnectAssets.Document.Create(xml); if (doc != null) { doc.UserObject = UserObject; doc.Url = response.RequestMessage.RequestUri.ToString(); Successful?.Invoke(doc); return(doc); } else { // Process MTConnectError Document (if MTConnectDevices fails) var errorDoc = MTConnectError.Document.Create(xml); if (errorDoc != null) { errorDoc.UserObject = UserObject; errorDoc.Url = response.RequestMessage.RequestUri.ToString(); Error?.Invoke(errorDoc); } } } } } return(null); }
protected void OnSuccessful(TEventArgs arg) => Successful?.Invoke(this, arg);
public void OnSuccess(Java.Lang.Object result) { Successful?.Invoke(this, new EventArgs()); }
void OnSuccessful(object sender, TEventArgs e) { Successful?.Invoke(this, e); }