public void Disconnect() { try { if (socket != null) { // ks 12/12/11 - We've been getting some 10057 errors here. The only way I can think that they might be happening // is if two threads are trying to close the socket simultaneously. I've added in some locking // code to help protect against that. We'll see if it makes any difference. lock (socket) { if (socket.Connected) { ClientLogger.Debug("Disconnecting from " + _endPoint); socket.Shutdown(SocketShutdown.Both); socket.Close(); } } } } catch (Exception ex) { // ks 05/11/12 - Switched from ErrorException to DebugException, as swallowing the exception seems to // work just fine. ClientLogger.DebugException(ex, "Disconnecting failed"); } }
private void HandleCaptureError(Exception ex) { ClientLogger.DebugException(ex, "Capture devices failed"); RaiseCaptureFailed(); if (CaptureSource != null) { if (CaptureSource.State == CaptureState.Started) { CaptureSource.Stop(); } CaptureSource.VideoCaptureDevice = null; } }
protected void Dispose(bool disposing) { if (_disposed) { return; } try { if (_userObserver != null) { _userObserver.Dispose(); } if (mediaElement != null && mediaElement.CurrentState != MediaElementState.Closed) { mediaElement.Stop(); mediaElement = null; } } catch (Exception ex) { ClientLogger.DebugException(ex, "Error on disposing"); } _disposed = true; }
public T GetConfigurationObject(string fileName) { try { string filePath = ConfigPrefix + fileName; if (!IsolatedStorageFile.GetUserStoreForSite().FileExists(filePath)) { return(new T()); } using (var stream = new IsolatedStorageFileStream(ConfigPrefix + fileName, FileMode.Open, IsolatedStorageFile.GetUserStoreForSite())) { var serializer = new XmlSerializer(typeof(T)); return(serializer.Deserialize(stream) as T); } } catch (FileNotFoundException ex) { ClientLogger.DebugException(ex, "The configuration file {0} was not found", fileName); return(new T()); } catch (IsolatedStorageException ex) { ClientLogger.ErrorException(ex, "The IsolatedStorage subsystem threw an error retrieving file {0}", fileName); return(new T()); } catch (InvalidOperationException ex) { ClientLogger.DebugException(ex, "InvalidOperationException error getting configuration file {0}", fileName); return(new T()); } catch (Exception ex) { ClientLogger.ErrorException(ex, "Unexpected error getting configuration file {0}", fileName); throw; } }