xtd 0.2.0
Loading...
Searching...
No Matches

◆ run() [2/3]

static void xtd::forms::application::run ( xtd::forms::application_context context)
static

Begins running a standard application message loop on the current thread, with an application_context.

Parameters
contextAn ApplicationContext in which the application is run.
Remarks
The message loop runs until xtd::forms::application::exit or xtd::forms::application::exit_thread is called or the xtd::forms::application_context::thread_exit event is raised on the context object.
Examples
The following code example demonstrates the use of application run method.
#include <xtd/forms/application>
#include <xtd/forms/application_context>
#include <xtd/forms/form>
using namespace xtd::forms;
auto main() -> int {
auto context = application_context {};
auto form1 = form::create("Form 1 (Click the client area to set form as the main form)");
form1.click += [&] {context.main_form(form1);};
form1.show();
auto form2 = form::create("Form 2 (Click the client area to set form as the main form)");
form2.click += [&] {context.main_form(form2);};
form2.show();
auto form3 = form::create("Form 3 (Click the client area to set form as the main form)");
form3.click += [&] {context.main_form(form3);};
form3.show();
// if no client area form clicked, the application will not exit when you close the forms.
application::run(context);
}
Specifies the contextual information about an application thread.
Definition application_context.h:26
static void run()
Begins running a standard application message loop on the current thread, without a form.
static form create()
A factory to create an xtd::forms::form.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12