Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public Tasks.Task <char?> Read()
 {
     lock (this.@lock)
     {
         var result = this.data ?? this.read();
         this.data = null;
         return(result);
     }
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
 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;
     }));
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 public Tasks.Task <char?> Peek()
 {
     lock (this.@lock)
         return(this.data ?? (this.data = this.read()));
 }
Exemplo n.º 12
0
 public async static Tasks.Task Then <T>(this Tasks.Task <T> me, Action <T> action)
 {
     action.Call(await me);
 }
Exemplo n.º 13
0
 public static void Forget <T>(this Tasks.Task <T> me)
 {
     me.ContinueWith(
         t => {; },
         Tasks.TaskContinuationOptions.OnlyOnFaulted);
 }
Exemplo n.º 14
0
 public async static Tasks.Task <TResult> Then <T, TResult>(this Tasks.Task <T> me, Func <T, TResult> map)
 {
     return(map(await me));
 }
Exemplo n.º 15
0
 public static ITextIndenter Open(out Tasks.Task <string> output)
 {
     return(TextIndenter.Open(TextWriter.Open(out output)));
 }
Exemplo n.º 16
0
 public static ITextWriter Open(out Tasks.Task <string> output)
 {
     return(TextWriter.Open(CharacterDevice.Open(out output)));
 }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
 public void Reset()
 {
     lock (this.@lock)
         this.data = null;
 }
Exemplo n.º 19
0
 public async Tasks.Task <char?> Peek()
 {
     return((this.peeked.NotNull() ? await this.peeked : null) ?? await(this.peeked = this.ReadBackend()));
 }
Exemplo n.º 20
0
 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);
 }
Exemplo n.º 21
0
 public static ICharacterOutDevice Open(out Tasks.Task <string> output)
 {
     return(CharacterOutDevice.Open(out output));
 }