public async Task <bool> StartAsync(SessionKinds kind)
        {
            try
            {
                switch (kind)
                {
                case SessionKinds.Unspecified:
                    _extendedExecutionSession.Reason = ExtendedExecutionReason.Unspecified;
                    break;

                case SessionKinds.LocationTracking:
                    _extendedExecutionSession.Reason = ExtendedExecutionReason.LocationTracking;
                    break;

                case SessionKinds.SavingData:
                    _extendedExecutionSession.Reason = ExtendedExecutionReason.SavingData;
                    break;

                default:
                    throw new NotSupportedException(kind.ToString());
                }
                var result = await _extendedExecutionSession.RequestExtensionAsync();

                return(result == ExtendedExecutionResult.Allowed);
            }
            catch
            {
                return(false);
            }
        }
Пример #2
0
 public async Task<bool> StartAsync(SessionKinds kind)
 {
     try
     {
         switch (kind)
         {
             case SessionKinds.None:
                 throw new NotSupportedException();
             case SessionKinds.Unspecified:
                 _extendedExecutionSession.Reason = ExtendedExecutionReason.Unspecified;
                 break;
             case SessionKinds.LocationTracking:
                 _extendedExecutionSession.Reason = ExtendedExecutionReason.LocationTracking;
                 break;
             case SessionKinds.SavingData:
                 _extendedExecutionSession.Reason = ExtendedExecutionReason.SavingData;
                 break;
         }
         var result = await _extendedExecutionSession.RequestExtensionAsync();
         return result == ExtendedExecutionResult.Allowed;
     }
     catch
     {
         return false;
     }
 }