Exemplo n.º 1
0
        /// <summary>
        ///     Create an <see cref="Unlocker" /> to release the <see cref="AsyncLocker" />
        /// </summary>
        /// <returns>The instance of <see cref="Unlocker" /> used to release <see cref="AsyncLocker" /></returns>
        public Task <Unlocker> LockAsync()
        {
            var waitTask = Semaphore.AsyncWait();

            return(waitTask.IsCompleted
                       ? TaskBuilder.FromResult(new Unlocker(this))
                       : waitTask.ContinueWith(task => new Unlocker(this),
                                               CancellationToken.None,
                                               TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default));
        }
 public Task HandleRequest(HttpParameter parameter, HttpRequest request)
 {
     try
     {
         //Get all attributed headers
         var headerList = Headers.GetOrAdd(parameter.GetType(), HandleType);
         headerList.ForEach(header => request.AddHeader(header.Key, header.Value));
         return(TaskBuilder.FromResult(true));
     }
     catch (Exception e)
     {
         Error(e);
         return(TaskBuilder.FromResult(false));
     }
 }