public static ICharacterOutDevice Open(out Tasks.Task <string> output) { var outputSource = new Tasks.TaskCompletionSource <string>(); output = outputSource.Task; return(CharacterOutDevice.Open(content => outputSource.SetResult(content))); }
public static T WaitFor <T>(this Tasks.Task <T> me, TimeSpan timeout, T @default = default(T)) { T result = @default; me.Then(r => result = r).Wait(timeout); return(result); }
public Tasks.Task <char?> Read() { lock (this.@lock) { var result = this.data ?? this.read(); this.data = null; return(result); } }
public async static Tasks.Task Then <T>(this Tasks.Task <T> me, Action <T> action, Action <Exception> onError) { try { await me.Then(action); } catch (System.Exception e) { onError.Call(e); } }
public Tasks.Task <char?> Decode(Generic.IEnumerator <Tasks.Task <byte?> > data) { return(this.Decode(() => { Tasks.Task <byte?> result = null; if (data.MoveNext()) { result = data.Current; } return result; })); }
public async static Tasks.Task <TResult> Then <T, TResult>(this Tasks.Task <T> me, Func <T, TResult> map, Func <Exception, TResult> onError) { TResult result; try { result = await me.Then(map); } catch (System.Exception e) { result = onError(e); } return(result); }
public async Tasks.Task <char?> Read() { var next = this.Peek(); this.peeked = null; this.Position = this.GetPosition(next); var onRead = this.OnRead; // Save OnRead so that it reflects the state when the read command was issued not when the result arrives. var result = await next; if (result.HasValue && onRead.NotNull()) { onRead(result.Value); } return(result); }
private async Tasks.Task multiselectButtonHelper(Tasks.Task <bool> multiselectActionTask, string errorMessage) { this.ViewModel.IsBusy = true; bool success = await multiselectActionTask; if (success) { Tasks.Task refreshTask = this.Refresh(); this.endMultiSelectMode(); await refreshTask; } else { await MessageCenter.ShowErrorMessage(errorMessage); } this.ViewModel.IsBusy = false; }
/// <summary> /// Get the QueryExpression used to query CRM for time entries. /// </summary> /// <returns>A new QueryExpression.</returns> private async Tasks.Task <QueryExpression> buildTimeQueryExpression() { // Start the owner id retrieval Tasks.Task <ConditionExpression> ownerFilterTask = this.getOwnerFilter(); // Build everything else for the QueryExpression QueryExpression retrieveTimeCollection = new QueryExpression(msdyn_timeentry.EntityLogicalName); retrieveTimeCollection.ColumnSet = new ColumnSet("msdyn_timeentryid", "msdyn_type", "msdyn_bookableresource", "msdyn_date", "msdyn_description", "msdyn_duration", "msdyn_entrystatus", "msdyn_externaldescription", "msdyn_project", "msdyn_projecttask", "modifiedon", "createdon"); retrieveTimeCollection.Distinct = true; retrieveTimeCollection.Criteria = new FilterExpression(); // Filter to selected month retrieveTimeCollection.Criteria.AddCondition(this.getCurrentPeriodFilter()); // Order by time entry date this.setOrderBy(retrieveTimeCollection); // Let the owner filter finish before we return. retrieveTimeCollection.Criteria.AddCondition(await ownerFilterTask); return(retrieveTimeCollection); }
private async void RecallButton_Clicked(object sender, EventArgs e) { // async void OK for top level event handler. Tasks.Task <bool> recallTask = this.viewModel.RecallSelectedTimeEntries(); await this.multiselectButtonHelper(recallTask, AppResources.RecallError); }
public Tasks.Task <char?> Peek() { lock (this.@lock) return(this.data ?? (this.data = this.read())); }
public async static Tasks.Task Then <T>(this Tasks.Task <T> me, Action <T> action) { action.Call(await me); }
public static void Forget <T>(this Tasks.Task <T> me) { me.ContinueWith( t => {; }, Tasks.TaskContinuationOptions.OnlyOnFaulted); }
public async static Tasks.Task <TResult> Then <T, TResult>(this Tasks.Task <T> me, Func <T, TResult> map) { return(map(await me)); }
public static ITextIndenter Open(out Tasks.Task <string> output) { return(TextIndenter.Open(TextWriter.Open(out output))); }
public static ITextWriter Open(out Tasks.Task <string> output) { return(TextWriter.Open(CharacterDevice.Open(out output))); }
async Tasks.Task <Text.Position> GetPosition(Tasks.Task <char?> next) { var c = await next; return(c.HasValue ? await this.Position + c.Value : await this.Position); }
public void Reset() { lock (this.@lock) this.data = null; }
public async Tasks.Task <char?> Peek() { return((this.peeked.NotNull() ? await this.peeked : null) ?? await(this.peeked = this.ReadBackend())); }
private async void SubmitButton_Clicked(object sender, EventArgs e) { // async void OK for top level event handler. Tasks.Task <bool> submitTask = this.viewModel.SubmitSelectedTimeEntries(); await this.multiselectButtonHelper(submitTask, AppResources.SubmitError); }
public static ICharacterOutDevice Open(out Tasks.Task <string> output) { return(CharacterOutDevice.Open(out output)); }