/// <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; }
/// <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; }
/// <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)); }
/* * 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()); } }
public TResult GetResult() { TaskAwaiter.ValidateEnd((Task)this.m_task); return(this.m_task.ResultOnSuccess); }
public TaskAwaiter(JoinableTask task) { awaiter = task.GetAwaiter(); }
public void UnsafeOnCompleted(Action continuation) { TaskAwaiter.OnCompletedInternal(this.m_task, continuation, this.m_continueOnCapturedContext, false); }
public void UnsafeOnCompleted(Action continuation) { TaskAwaiter.OnCompletedInternal((Task)this.m_task, continuation, true, false); }
public void UnsafeOnCompleted(Action continuation) { TaskAwaiter.OnCompletedInternal(_task, continuation, true); }
/// <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); }
/// <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); }
/// <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; }
internal TaskAwaiter(TaskController taskController, SystemTasks.Task awaitedTask) { this.TaskController = taskController; this.AwaitedTask = awaitedTask; this.Awaiter = awaitedTask.GetAwaiter(); }
/// <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) "确认"); } }
public void JoinTillEmptyAlreadyCompleted() { System.Runtime.CompilerServices.TaskAwaiter awaiter = this.joinableCollection !.JoinTillEmptyAsync().GetAwaiter(); Assert.True(awaiter.IsCompleted); }
/// <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); }
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); }
public void UnsafeOnCompleted(Action continuation) { TaskAwaiter.OnCompletedInternal(m_task, continuation, m_continueOnCapturedContext, flowExecutionContext: false); }
/// <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); }
/// <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(); }
public void OnCompleted(Action continuation) => TaskAwaiter.OnCompletedInternal(_t, continuation, _capturedContext);
/// <summary> /// Wraps the specified task awaiter. /// </summary> public static TaskAwaiter Wrap(SystemCompiler.TaskAwaiter awaiter) => new TaskAwaiter(null, awaiter);
public void OnCompleted(Action continuation) { TaskAwaiter.OnCompletedInternal((Task)this.m_task, continuation, this.m_continueOnCapturedContext, true); }