public bool Update(UpdatePriorities updatePriority = UpdatePriorities.Normal, UpdateStyles updateStyle = UpdateStyles.Async, bool avoidNotConnectedExceptions = true) { EnsureAttached(); EnsureImageUpdaterNotNull(); uint result = MethodsWrapper.UpdateBitmap(openByTypeContext.device, ImageUpdater.UnmanagedBitmapHeaderPointer, ((uint)updateStyle) | ((uint)updatePriority)); switch (result) { case (uint)Errors.ERROR_SUCCESS: break; case (uint)Errors.ERROR_SERVICE_NOT_ACTIVE: throw new DeviceException(result, "Lglcd.Initialize() has not been called yet"); case (uint)Errors.ERROR_INVALID_PARAMETER: throw new DeviceException(result, "Device handle is invalid or image is invalid"); case (uint)Errors.ERROR_DEVICE_NOT_CONNECTED: // We try to avoid throwing this exception type because it happens really often if (avoidNotConnectedExceptions) return false; // Not connected means it has been usb-removed, that's why I don't use "detached" throw new DeviceException(result, "Device not connected"); case (uint)Errors.ERROR_ACCESS_DENIED: throw new DeviceException(result, "Synchronous operation was not displayed on the LCD within the frame interval (30 ms). Error happens only with UpdateStyles.SyncComplete"); default: throw new DeviceException(result, "Problems updating device image"); } return true; }
public bool Update(UpdatePriorities updatePriority = UpdatePriorities.Normal, UpdateStyles updateStyle = UpdateStyles.Async, bool avoidNotConnectedExceptions = true) { EnsureAttached(); EnsureImageUpdaterNotNull(); uint result = MethodsWrapper.UpdateBitmap(openByTypeContext.device, ImageUpdater.UnmanagedBitmapHeaderPointer, ((uint)updateStyle) | ((uint)updatePriority)); switch (result) { case (uint)Errors.ERROR_SUCCESS: break; case (uint)Errors.ERROR_SERVICE_NOT_ACTIVE: throw new DeviceException(result, "Lglcd.Initialize() has not been called yet"); case (uint)Errors.ERROR_INVALID_PARAMETER: throw new DeviceException(result, "Device handle is invalid or image is invalid"); case (uint)Errors.ERROR_DEVICE_NOT_CONNECTED: // We try to avoid throwing this exception type because it happens really often if (avoidNotConnectedExceptions) { return(false); } // Not connected means it has been usb-removed, that's why I don't use "detached" throw new DeviceException(result, "Device not connected"); case (uint)Errors.ERROR_ACCESS_DENIED: throw new DeviceException(result, "Synchronous operation was not displayed on the LCD within the frame interval (30 ms). Error happens only with UpdateStyles.SyncComplete"); default: throw new DeviceException(result, "Problems updating device image"); } return(true); }