Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAwaiter"/> struct.
 /// </summary>
 private TaskAwaiter(SystemTask awaitedTask, ref SystemCompiler.TaskAwaiter awaiter)
 {
     this.AwaitedTask = awaitedTask;
     this.Awaiter     = awaiter;
     RuntimeProvider.TryGetFromSynchronizationContext(out CoyoteRuntime runtime);
     this.Runtime = runtime;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAwaiter"/> struct.
 /// </summary>
 internal TaskAwaiter(SystemTask awaitedTask)
 {
     this.AwaitedTask = awaitedTask;
     this.Awaiter     = awaitedTask.GetAwaiter();
     RuntimeProvider.TryGetFromSynchronizationContext(out CoyoteRuntime runtime);
     this.Runtime = runtime;
 }
Beispiel #3
0
        /// <summary>
        /// Wraps the specified task awaiter.
        /// </summary>
        public static TaskAwaiter Wrap(SystemCompiler.TaskAwaiter awaiter)
        {
            // Access the task being awaited through reflection.
            var field       = awaiter.GetType().GetField("m_task", BindingFlags.NonPublic | BindingFlags.Instance);
            var awaitedTask = (SystemTask)field?.GetValue(awaiter);

            return(new TaskAwaiter(awaitedTask, ref awaiter));
        }
Beispiel #4
0
    /*
     * Default Required To Initialize the MainAsync() method.
     */
    public static void Main(string[] args)
    {
        Program p = new Program();

        int length = (int)CacheReader.Open();

        cache = CacheReader.SeekCache(0, length, length + 8192);
        CacheReader.Close();

        Task task = p.MainAsync();

        System.Runtime.CompilerServices.TaskAwaiter await = task.GetAwaiter();
        try
        {
            await.GetResult();
        } catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
    }
Beispiel #5
0
 public TResult GetResult()
 {
     TaskAwaiter.ValidateEnd((Task)this.m_task);
     return(this.m_task.ResultOnSuccess);
 }
Beispiel #6
0
 public TaskAwaiter(JoinableTask task)
 {
     awaiter = task.GetAwaiter();
 }
 public void UnsafeOnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal(this.m_task, continuation, this.m_continueOnCapturedContext, false);
 }
Beispiel #8
0
 public void UnsafeOnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal((Task)this.m_task, continuation, true, false);
 }
Beispiel #9
0
 public void UnsafeOnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal(_task, continuation, true);
 }
Beispiel #10
0
 /// <summary>
 ///     Schedules the continuation onto the <see cref="T:System.Threading.Tasks.Task" /> associated with this
 ///     <see cref="T:System.Runtime.CompilerServices.TaskAwaiter" />.
 /// </summary>
 /// <param name="continuation">The action to invoke when the await operation completes.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///     The <paramref name="continuation" /> argument is null (Nothing in
 ///     Visual Basic).
 /// </exception>
 /// <exception cref="T:System.NullReferenceException">The awaiter was not properly initialized.</exception>
 /// <remarks>
 ///     This method is intended for compiler user rather than use directly in code.
 /// </remarks>
 public void OnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal(_task, continuation, _continueOnCapturedContext);
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAwaiter"/> struct.
 /// </summary>
 internal TaskAwaiter(CoyoteRuntime runtime, SystemCompiler.TaskAwaiter awaiter)
 {
     this.Runtime     = runtime;
     this.AwaitedTask = null;
     this.Awaiter     = awaiter;
 }
 public void OnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal(this.m_task, continuation, true);
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAwaiter"/> struct.
 /// </summary>
 private TaskAwaiter(SystemTasks.Task awaitedTask, SystemCompiler.TaskAwaiter awaiter)
 {
     this.AwaitedTask = awaitedTask;
     this.Awaiter     = awaiter;
 }
Beispiel #14
0
 internal TaskAwaiter(TaskController taskController, SystemTasks.Task awaitedTask)
 {
     this.TaskController = taskController;
     this.AwaitedTask    = awaitedTask;
     this.Awaiter        = awaitedTask.GetAwaiter();
 }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAwaiter"/> struct.
 /// </summary>
 internal TaskAwaiter(SystemTasks.Task awaitedTask)
 {
     this.AwaitedTask = awaitedTask;
     this.Awaiter     = awaitedTask.GetAwaiter();
 }
 private async void SaveButton_Click(object sender, RoutedEventArgs e)
 {
   ApplicationDataContainer localsettings = ApplicationData.get_Current().get_LocalSettings();
   ((IDictionary<string, object>) localsettings.get_Values())["season"] = ((ContentControl) ((Selector) this.Season).get_SelectedItem()).get_Content();
   ((IDictionary<string, object>) localsettings.get_Values())["weekNumber"] = (object) ((Selector) this.CurrentWeekNumber).get_SelectedIndex();
   IPropertySet values = localsettings.get_Values();
   string index = "weekDate";
   DateTime today = DateTime.Today;
   int dayOfYear = today.DayOfYear;
   today = DateTime.Today;
   int num1;
   if (today.DayOfWeek != DayOfWeek.Sunday)
   {
     today = DateTime.Today;
     num1 = (int) (today.DayOfWeek - 1);
   }
   else
     num1 = 6;
   // ISSUE: variable of a boxed type
   __Boxed<int> local = (ValueType) (dayOfYear - num1);
   ((IDictionary<string, object>) values)[index] = (object) local;
   if (((ContentControl) this.SaveButton).get_Content().ToString() == "确认")
   {
     if (this.UserName.get_Text() != "" && this.MyPasswordBox.get_Password() != "")
     {
       ((IDictionary<string, object>) localsettings.get_Values())["userName"] = (object) this.UserName.get_Text();
       ((IDictionary<string, object>) localsettings.get_Values())["password"] = (object) this.MyPasswordBox.get_Password();
       ((ContentControl) this.SaveButton).put_Content((object) "删除");
     }
     else
     {
       MessageDialog message = new MessageDialog("不要卖萌,没有数据怎么确认~");
       TaskAwaiter<IUICommand> awaiter = (TaskAwaiter<IUICommand>) WindowsRuntimeSystemExtensions.GetAwaiter<IUICommand>((IAsyncOperation<M0>) message.ShowAsync());
       if (!awaiter.IsCompleted)
       {
         int num2;
         // ISSUE: reference to a compiler-generated field
         this.\u003C\u003E1__state = num2 = 0;
         TaskAwaiter<IUICommand> taskAwaiter = awaiter;
         // ISSUE: variable of a compiler-generated type
         MainPage.\u003CSaveButton_Click\u003Ed__31 stateMachine = this;
         // ISSUE: reference to a compiler-generated field
         this.\u003C\u003Et__builder.AwaitUnsafeOnCompleted<TaskAwaiter<IUICommand>, MainPage.\u003CSaveButton_Click\u003Ed__31>(ref awaiter, ref stateMachine);
       }
       else
       {
         awaiter.GetResult();
         awaiter = new TaskAwaiter<IUICommand>();
         message = (MessageDialog) null;
       }
     }
   }
   else
   {
     ((IDictionary<string, object>) localsettings.get_Values()).Remove("userName");
     ((IDictionary<string, object>) localsettings.get_Values()).Remove("password");
     await DataHelper.DeleteDatabaseAsync();
     this.UserName.put_Text("");
     this.MyPasswordBox.put_Password("");
     ((ContentControl) this.SaveButton).put_Content((object) "确认");
   }
 }
Beispiel #17
0
 public void JoinTillEmptyAlreadyCompleted()
 {
     System.Runtime.CompilerServices.TaskAwaiter awaiter = this.joinableCollection !.JoinTillEmptyAsync().GetAwaiter();
     Assert.True(awaiter.IsCompleted);
 }
Beispiel #18
0
 /// <summary>Ends the await on the completed <see cref="System.Threading.Tasks.Task"/>.</summary>
 /// <returns>The result of the completed <see cref="System.Threading.Tasks.Task{TResult}"/>.</returns>
 /// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
 /// <exception cref="System.Threading.Tasks.TaskCanceledException">The task was canceled.</exception>
 /// <exception cref="System.Exception">The task completed in a Faulted state.</exception>
 public void GetResult()
 {
     TaskAwaiter.ValidateEnd(m_task);
 }
Beispiel #19
0
 private void ProcessAuthenticationResponse(TaskAwaiter<bool?> authenticationAwaiter, GossipConnection gossipConnection)
 {
     bool? result;
     try
     {
         result = authenticationAwaiter.GetResult();
     }
     catch (IOException)
     {
         return;
     }
     if (!result.HasValue) return;
     if (!result.Value)
     {
         OnClientConnectionAuthenticationFailed(this, gossipConnection);
         return;
     }
     ClientConnectionAuthenticationSucceeded(gossipConnection);
     OnClientConnectionAuthenticationSucceeded(this, gossipConnection);
 }
Beispiel #20
0
 public void UnsafeOnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal(m_task, continuation, m_continueOnCapturedContext, flowExecutionContext: false);
 }
Beispiel #21
0
 /// <summary>
 ///     Ends the await on the completed <see cref="T:System.Threading.Tasks.Task`1" />.
 /// </summary>
 /// <returns>
 ///     The result of the completed <see cref="T:System.Threading.Tasks.Task`1" />.
 /// </returns>
 /// <exception cref="T:System.NullReferenceException">The awaiter was not properly initialized.</exception>
 /// <exception cref="T:System.InvalidOperationException">The task was not yet completed.</exception>
 /// <exception cref="T:System.Threading.Tasks.TaskCanceledException">The task was canceled.</exception>
 /// <exception cref="T:System.Exception">The task completed in a Faulted state.</exception>
 public TResult GetResult()
 {
     TaskAwaiter.ValidateEnd(_task);
     return(_task.Result);
 }
Beispiel #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAwaiter"/> struct.
 /// </summary>
 internal TaskAwaiter(CoyoteRuntime runtime, SystemTasks.Task awaitedTask)
 {
     this.Runtime     = runtime;
     this.AwaitedTask = awaitedTask;
     this.Awaiter     = awaitedTask.GetAwaiter();
 }
Beispiel #23
0
 public void OnCompleted(Action continuation) => TaskAwaiter.OnCompletedInternal(_t, continuation, _capturedContext);
Beispiel #24
0
 /// <summary>
 /// Wraps the specified task awaiter.
 /// </summary>
 public static TaskAwaiter Wrap(SystemCompiler.TaskAwaiter awaiter) => new TaskAwaiter(null, awaiter);
Beispiel #25
0
 public void OnCompleted(Action continuation)
 {
     TaskAwaiter.OnCompletedInternal((Task)this.m_task, continuation, this.m_continueOnCapturedContext, true);
 }