public void Constructor_ExceptionIsProvided_ExceptionPropertyIsSetAndFilePathPropertyIsNotSet() { var exception = new Exception(); var fileWatcherErrorEventArgs = new FileWatcherErrorEventArgs(exception); Assert.AreEqual(exception, fileWatcherErrorEventArgs.Exception); Assert.IsNull(fileWatcherErrorEventArgs.FilePath); }
public void Constructor_ExceptionAndFilePathIsProvided_PropertiesAreSet() { var exception = new Exception(); var filePath = @"C:\Temp\testfile.txt"; var fileWatcherErrorEventArgs = new FileWatcherErrorEventArgs(exception, filePath); Assert.AreEqual(exception, fileWatcherErrorEventArgs.Exception); Assert.AreEqual(filePath, fileWatcherErrorEventArgs.FilePath); }
//Function GetMaxInternalBuffersize() As Integer // 'NOTE: Only increase FSW InternalBuffersize after evaluation other options: // ' http://msdn.microsoft.com/en-us/library/ded0dc5s.aspx // ' http://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx // Dim maxInternalBufferSize64BitOS = ByteSize.ByteSize.FromKiloBytes(16 * 4) // Dim maxInternalBufferSize32BitOS = ByteSize.ByteSize.FromKiloBytes(2 * 4) // If Environment.Is64BitOperatingSystem Then // Return maxInternalBufferSize64BitOS.Bytes // Else // Return maxInternalBufferSize32BitOS.Bytes // End If //End Function private bool ExceptionWasHandledByCaller(Exception ex) { //Allow consumer to handle error if (_onErrorHandler != null) { FileWatcherErrorEventArgs e = new FileWatcherErrorEventArgs(ex); InvokeHandler(_onErrorHandler, e); return(e.Handled); } return(false); }
private void InvokeHandler(EventHandler <FileWatcherErrorEventArgs> eventHandler, FileWatcherErrorEventArgs e) { if (eventHandler != null) { if (SynchronizingObject != null && this.SynchronizingObject.InvokeRequired) { SynchronizingObject.BeginInvoke(eventHandler, new object[] { this, e }); } else { eventHandler(this, e); } } }
private void _watcher_Error(object sender, FileWatcherErrorEventArgs e) { Trace.TraceError(e.Error.Message); e.Handled = true; }
private void InvokeHandler(EventHandler<FileWatcherErrorEventArgs> eventHandler, FileWatcherErrorEventArgs e) { if (eventHandler != null) { if (SynchronizingObject != null && this.SynchronizingObject.InvokeRequired) SynchronizingObject.BeginInvoke(eventHandler, new object[] { this, e }); else eventHandler(this, e); } }
//Function GetMaxInternalBuffersize() As Integer // 'NOTE: Only increase FSW InternalBuffersize after evaluation other options: // ' http://msdn.microsoft.com/en-us/library/ded0dc5s.aspx // ' http://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx // Dim maxInternalBufferSize64BitOS = ByteSize.ByteSize.FromKiloBytes(16 * 4) // Dim maxInternalBufferSize32BitOS = ByteSize.ByteSize.FromKiloBytes(2 * 4) // If Environment.Is64BitOperatingSystem Then // Return maxInternalBufferSize64BitOS.Bytes // Else // Return maxInternalBufferSize32BitOS.Bytes // End If //End Function private bool ExceptionWasHandledByCaller(Exception ex) { //Allow consumer to handle error if (_onErrorHandler != null) { FileWatcherErrorEventArgs e = new FileWatcherErrorEventArgs(ex); InvokeHandler(_onErrorHandler, e); return e.Handled; } else { return false; } }
private async void OnError(object source, FileWatcherErrorEventArgs e) => await Task.Run(() => { logger.LogError(e.Exception, "Error while watching"); });