Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9261


Ignore:
Timestamp:
02/28/13 20:34:19 (12 years ago)
Author:
ascheibe
Message:

#2019 because GetUser sometimes fails try to repeat it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Access/3.3/UserManager.cs

    r8040 r9261  
    2929  public class UserManager : IUserManager {
    3030    public MembershipUser CurrentUser {
    31       get { return Membership.GetUser(); }
     31      get { return TryAndRepeat(() => { return Membership.GetUser(); }); }
    3232    }
    3333
     
    8080      return false;
    8181    }
     82
     83    private static T TryAndRepeat<T>(Func<T> action) {
     84      int repetitions = 5;
     85      while (true) {
     86        try { return action(); }
     87        catch (Exception e) {
     88          if (repetitions == 0) throw e;
     89          repetitions--;
     90        }
     91      }
     92    }
    8293  }
    8394}
Note: See TracChangeset for help on using the changeset viewer.