Modify exception handling OUT-445
authorThomas
Tue, 19 Nov 2019 10:00:19 +0100
branchOUT-445
changeset 28713f9df2a701d7
parent 2870 c2591bdbb6f7
child 2891 88f32070118f
Modify exception handling
UI/FormControlOptions.xaml.cs
     1.1 --- a/UI/FormControlOptions.xaml.cs	Tue Nov 19 09:40:47 2019 +0100
     1.2 +++ b/UI/FormControlOptions.xaml.cs	Tue Nov 19 10:00:19 2019 +0100
     1.3 @@ -1018,31 +1018,31 @@
     1.4              /// </summary>
     1.5              private async void CheckForUpdates()
     1.6              {
     1.7 -                try
     1.8 +                bool updateFound = false;
     1.9 +                this.IsCheckingForUpdates = true;
    1.10 +                await Task.Run(() =>
    1.11                  {
    1.12 -                    bool updateFound = false;
    1.13 -                    this.IsCheckingForUpdates = true;
    1.14 -                    await Task.Run(() =>
    1.15 +                    string updateStr = string.Format(Properties.Settings.Default.UpdateURL, Properties.Settings.Default.Serial);
    1.16 +                    try
    1.17                      {
    1.18 -                        string updateStr = string.Format(Properties.Settings.Default.UpdateURL, Properties.Settings.Default.Serial);
    1.19                          ThisAddIn.PEPEngine.UpdateNow(updateStr, out updateFound);
    1.20 -                    });
    1.21 -                    this.IsCheckingForUpdates = false;
    1.22 +                    }
    1.23 +                    catch (Exception ex)
    1.24 +                    {
    1.25 +                        updateFound = false;
    1.26 +                        Log.Error("CheckForUpdates: Error checking for updates. " + ex.ToString());
    1.27 +                    }
    1.28 +                });
    1.29 +                this.IsCheckingForUpdates = false;
    1.30  
    1.31 -                    // TODO: communicate result to user
    1.32 -                    if (updateFound)
    1.33 -                    {
    1.34 -                        // Notification
    1.35 -                    }
    1.36 -                    else
    1.37 -                    {
    1.38 +                // TODO: communicate result to user
    1.39 +                if (updateFound)
    1.40 +                {
    1.41 +                    // Notification
    1.42 +                }
    1.43 +                else
    1.44 +                {
    1.45  
    1.46 -                    }
    1.47 -                }
    1.48 -                catch (Exception ex)
    1.49 -                {
    1.50 -                    Log.Error("CheckForUpdates: Error checking for updates. " + ex.ToString());
    1.51 -                    this.IsCheckingForUpdates = false;
    1.52                  }
    1.53              }
    1.54  
    1.55 @@ -1124,7 +1124,7 @@
    1.56                      Log.Verbose("OpenDialogAndImportKeys: Fingerprint is null. Nothing done.");
    1.57                      return;
    1.58                  }
    1.59 -                
    1.60 +
    1.61                  // Create the dialog to select the key file
    1.62                  OpenFileDialog openFileDialog = new OpenFileDialog
    1.63                  {
    1.64 @@ -1144,7 +1144,7 @@
    1.65                           * Note 2: The following expected the user to introduce the correct
    1.66                           * fingerprint and use the corresponding key file. If the user doesn't
    1.67                           * provide the correct key/fpr pair, the import process fails.
    1.68 -                         */ 
    1.69 +                         */
    1.70                          string key = File.ReadAllText(openFileDialog.FileName);
    1.71                          ThisAddIn.PEPEngine.ImportKey(key, out pEpIdentity[] privateIdentities);
    1.72                          pEpIdentity privateIdentity = privateIdentities[0];