示例#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)));
        }
示例#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);
        }
示例#3
0
 public Tasks.Task <char?> Read()
 {
     lock (this.@lock)
     {
         var result = this.data ?? this.read();
         this.data = null;
         return(result);
     }
 }
示例#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);
     }
 }
示例#5
0
文件: Encoding.cs 项目: Spaxys/Kean
 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;
     }));
 }
示例#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);
        }
示例#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;
        }
示例#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);
        }
 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);
 }
示例#11
0
 public Tasks.Task <char?> Peek()
 {
     lock (this.@lock)
         return(this.data ?? (this.data = this.read()));
 }
示例#12
0
 public async static Tasks.Task Then <T>(this Tasks.Task <T> me, Action <T> action)
 {
     action.Call(await me);
 }
示例#13
0
 public static void Forget <T>(this Tasks.Task <T> me)
 {
     me.ContinueWith(
         t => {; },
         Tasks.TaskContinuationOptions.OnlyOnFaulted);
 }
示例#14
0
 public async static Tasks.Task <TResult> Then <T, TResult>(this Tasks.Task <T> me, Func <T, TResult> map)
 {
     return(map(await me));
 }
示例#15
0
 public static ITextIndenter Open(out Tasks.Task <string> output)
 {
     return(TextIndenter.Open(TextWriter.Open(out output)));
 }
示例#16
0
文件: TextWriter.cs 项目: Spaxys/Kean
 public static ITextWriter Open(out Tasks.Task <string> output)
 {
     return(TextWriter.Open(CharacterDevice.Open(out output)));
 }
示例#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);
        }
示例#18
0
 public void Reset()
 {
     lock (this.@lock)
         this.data = null;
 }
示例#19
0
 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);
 }
示例#21
0
 public static ICharacterOutDevice Open(out Tasks.Task <string> output)
 {
     return(CharacterOutDevice.Open(out output));
 }