Exemplo n.º 1
0
        private void OnWindowTextChanged(object sender, TextUpdatedEventArgs e)
        {
            SynchronizationContext syncContext = SynchronizationContext.Current;

            Task.Run(async() =>
            {
                mutex.WaitOne();
                if (lastContext != null && waitTask.IsCompleted == false)
                {
                    if (waitTask.IsCompleted == false)
                    {
                        lastContext.InternalCancellationProvider.Cancel();
                        waitTask.Wait();
                    }
                    lastContext.Dispose();
                }
                Command command          = new Command(e.Value);
                IInternalContext context = new QuickContext(command);
                AppDelegate app          = appBuilder.Build();
                await app(context);
                lastContext = context;
                syncContext.Send(s =>
                                 waitTask = lastContext.WaitResults(actions).ContinueWith(tsk =>
                {
                    if (tsk.Status == TaskStatus.RanToCompletion)
                    {
                        syncContext.Send(st => window.OnActionUpdateCompleted(), null);
                    }
                }), null);
                mutex.Set();
            });
        }