Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/21/12 13:42:34 (12 years ago)
Author:
ascheibe
Message:

#1648 fetch user and client information when the optimizer starts

Location:
trunk/sources/HeuristicLab.Clients.Access/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Access/3.3/ClientInformation.cs

    r8042 r8076  
    2222using System;
    2323using System.ServiceModel.Security;
     24using System.Threading.Tasks;
    2425
    2526namespace HeuristicLab.Clients.Access {
     
    2829    public static ClientInformation Instance {
    2930      get {
    30         if (instance == null) instance = new ClientInformation();
     31        InitializeClientInformation();
    3132        return instance;
    3233      }
     
    5455
    5556    private ClientInformation() {
    56       if (ClientInformationUtils.IsClientHeuristicLab()) {
    57         FetchClientInformationFromServer();
    58       } else {
    59         // this means we are executed by an Hive slave, therefore we just get our machine id (e.g. for OKB Algs)
    60         // because the slave has already done the registration process
    61         GenerateLocalClientConfig();
     57      if (instance == null) {
     58        if (ClientInformationUtils.IsClientHeuristicLab()) {
     59          FetchClientInformationFromServer();
     60        } else {
     61          // this means we are executed by an Hive slave, therefore we just get our machine id (e.g. for OKB Algs)
     62          // because the slave has already done the registration process
     63          GenerateLocalClientConfig();
     64        }
    6265      }
    6366    }
     
    100103      FetchClientInformationFromServer();
    101104    }
     105
     106    private static void InitializeClientInformation() {
     107      if (instance == null) instance = new ClientInformation();
     108    }
     109
     110    public static void InitializeAsync() {
     111      Task.Factory.StartNew(InitializeClientInformation);
     112    }
    102113  }
    103114}
  • trunk/sources/HeuristicLab.Clients.Access/3.3/UserInformation.cs

    r8043 r8076  
    2222using System;
    2323using System.ServiceModel.Security;
     24using System.Threading.Tasks;
    2425
    2526namespace HeuristicLab.Clients.Access {
     
    3031    public static UserInformation Instance {
    3132      get {
    32         if (instance == null) instance = new UserInformation();
     33        InitializeUserInformation();
    3334        return instance;
    3435      }
     
    6162
    6263    private UserInformation() {
    63       //this blocks, so there should be anywhere in the Optimizer startup process
    64       //a call to FetchUserInformationFromServerAsync which is non-blocking
    65       FetchUserInformationFromServer();
     64      if (instance == null) {
     65        FetchUserInformationFromServer();
     66      }
    6667    }
    67 
    6868
    6969    private void FetchUserInformationFromServer() {
     
    9292      FetchUserInformationFromServer();
    9393    }
     94
     95    private static void InitializeUserInformation() {
     96      if (instance == null) instance = new UserInformation();
     97    }
     98
     99    public static void InitializeAsync() {
     100      Task.Factory.StartNew(InitializeUserInformation);
     101    }
    94102  }
    95103}
Note: See TracChangeset for help on using the changeset viewer.