private void CallServiceMethod(Action <FanControlServiceClient> action) { try { if (client == null) { client = new FanControlServiceClient(); client.Open(); } action(client); } catch (Exception) { client.Abort(); client = null; } }
private void CallServiceMethod(Action <FanControlServiceClient> action) { try { if (client == null) { client = new FanControlServiceClient(); client.Open(); } action(client); } catch (Exception e) { logger.Warn(e, "Attempt to call a service method failed"); client.Abort(); client = null; } }
private void InitializeClient() { try { if (client == null || client.State == CommunicationState.Closed || client.State == CommunicationState.Closing || client.State == CommunicationState.Faulted) { client = new FanControlServiceClient(); } if (client.State != CommunicationState.Opened || client.State != CommunicationState.Opening) { client.Open(); } } catch { } }
private void Dispose(bool disposeManagedResources) { if (!disposed) { if (disposeManagedResources) { if (client != null) { try { client.Close(); } catch { } this.client = null; } } disposed = true; } }
private static void CallServiceMethod(Action <FanControlServiceClient> action) { try { using (var client = new FanControlServiceClient()) { client.Open(); action(client); client.Close(); } } catch (CommunicationObjectFaultedException) { Console.Error.WriteLine("The service is unavailable"); } catch (TimeoutException) { Console.Error.WriteLine("The connection to the service timed out"); } catch (Exception e) { Console.Error.WriteLine(e.Message); } }
private static void CallServiceMethod(Action<FanControlServiceClient> action) { try { using (var client = new FanControlServiceClient()) { client.Open(); action(client); client.Close(); } } catch (CommunicationObjectFaultedException) { Console.Error.WriteLine("The service is unavailable"); } catch (TimeoutException) { Console.Error.WriteLine("The connection to the service timed out"); } catch (Exception e) { Console.Error.WriteLine(e.Message); } }