protected async void OnCancelCommand()
 {
     try
     {
         //dont exit app on sharing
         if ((!SharingProcess) && (ImageFiles == null || ImageFiles?.Count == 0) || (_selectedFiles == null || _selectedFiles?.Count() != 0))
         {
             _applicationService.Exit();
         }
         else
         {
             foreach (var imagefile in ImageFiles)
             {
                 if (imagefile != null)
                 {
                     imagefile.Stream?.Dispose();
                     imagefile.Stream = null;
                 }
             }
             ImageFiles.Clear();
             LastFile?.Stream?.Dispose();
             LastFile = null;
         }
         SharingProcess = false;
         await _localSettings.SaveSettingsAsync();
     }
     catch (Exception e)
     {
         _loggerService?.LogException(nameof(OnCancelCommand), e);
     }
     _loggerService?.LogEvent(nameof(OnCancelCommand));
 }