PowerArgs.Cli.ConsoleApp.Start C# (CSharp) Method

Start() public method

Starts the app, asynchronously.
public Start ( ) : Task
return Task
        public override Task Start()
        {
            QueueAction(() =>
            {
                if (_current != null)
                {
                    throw new NotSupportedException("An application is already running on this thread.");
                }
                // ensures that the current app is set on the message pump thread
                _current = this;
            });

            if (SetFocusOnStart)
            {
                QueueAction(() =>
                {
                    FocusManager.TryMoveFocus();
                });
            }

            Paint();

            Task pumpTask = base.Start();

            var cleanupTask = pumpTask.ContinueWith((t) =>
            {
                 ExitInternal();
            });

            return cleanupTask;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Starts a new ConsoleApp and waits for it to finish
        /// </summary>
        /// <param name="init">the function that initializes the app</param>
        public static void Show(Action <ConsoleApp> init)
        {
            var app = new ConsoleApp();

            app.QueueAction(() => init(app));
            app.Start().Wait();
        }
All Usage Examples Of PowerArgs.Cli.ConsoleApp::Start