Specifies the contextual information about an application thread. 
- Header
 #include <xtd/forms/application_context>
  
- Namespace
 - xtd::forms 
 
- Library
 - xtd.forms
 
- Examples
 - The following code example demonstrates the use of application and application_context classes. 
#include <xtd/forms/application>
#include <xtd/forms/application_context>
#include <xtd/forms/form>
 
 
auto main() -> int {
  
  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();
  
  
}
Specifies the contextual information about an application thread.
Definition application_context.hpp:26
 
   
- Examples
 - application_context.cpp.
 
 | 
| std::optional< const_form_ref >  | main_form () const noexcept | 
|   | Gets the form to use as context.  
  | 
|   | 
| std::optional< form_ref >  | main_form () noexcept | 
|   | Gets or sets the Form to use as context.  
  | 
|   | 
| void  | main_form (const form &main_form) | 
|   | Sets the Form to use as context.  
  | 
|   | 
| void  | main_form (std::nullptr_t) | 
|   | Resets the Form to use as context.  
  | 
|   | 
| std::any  | tag () const noexcept | 
|   | Gets an object that contains data about the control.  
  | 
|   | 
| void  | tag (std::any tag) | 
|   | Sets an object that contains data about the control.  
  | 
|   | 
 | 
| void  | exit_thread () | 
|   | Terminates the message loop of the thread.  
  | 
|   | 
 | 
|   | object ()=default | 
|   | Create a new instance of the ultimate base class object.  
  | 
|   | 
| virtual bool  | equals (const object &obj) const noexcept | 
|   | Determines whether the specified object is equal to the current object.  
  | 
|   | 
| virtual size_t  | get_hash_code () const noexcept | 
|   | Serves as a hash function for a particular type.  
  | 
|   | 
| virtual type_object  | get_type () const noexcept | 
|   | Gets the type of the current instance.  
  | 
|   | 
| template<typename object_t >  | 
| xtd::uptr< object_t >  | memberwise_clone () const | 
|   | Creates a shallow copy of the current object.  
  | 
|   | 
| virtual xtd::string  | to_string () const noexcept | 
|   | Returns a xtd::string that represents the current object.  
  | 
|   | 
| template<typename object_a_t , typename object_b_t >  | 
| static bool  | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept | 
|   | Determines whether the specified object instances are considered equal.  
  | 
|   | 
| template<typename object_a_t , typename object_b_t >  | 
| static bool  | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept | 
|   | Determines whether the specified object instances are the same instance.  
  | 
|   | 
◆ application_context() [1/2]
      
        
          | xtd::forms::application_context::application_context  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ application_context() [2/2]
  
  
      
        
          | xtd::forms::application_context::application_context  | 
          ( | 
          const form &  | 
          main_form | ) | 
           | 
         
       
   | 
  
explicitnoexcept   | 
  
 
Initializes a new instance of the application_context class with the specified Form. 
- Parameters
 - 
  
    | main_form | The main form of the application to use for context.  | 
  
   
 
 
◆ main_form() [1/4]
  
  
      
        
          | std::optional< const_form_ref > xtd::forms::application_context::main_form  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
noexcept   | 
  
 
Gets the form to use as context. 
- Returns
 - The form to use as context. 
 
 
 
◆ main_form() [2/4]
  
  
      
        
          | std::optional< form_ref > xtd::forms::application_context::main_form  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
noexcept   | 
  
 
Gets or sets the Form to use as context. 
- Returns
 - The form to use as context. 
 
 
 
◆ main_form() [3/4]
      
        
          | void xtd::forms::application_context::main_form  | 
          ( | 
          const form &  | 
          main_form | ) | 
           | 
        
      
 
Sets the Form to use as context. 
- Parameters
 - 
  
    | main_form | The form to use as context.  | 
  
   
 
 
◆ main_form() [4/4]
      
        
          | void xtd::forms::application_context::main_form  | 
          ( | 
          std::nullptr_t  | 
           | ) | 
           | 
        
      
 
Resets the Form to use as context. 
- Parameters
 - 
  
  
 
 
 
◆ tag() [1/2]
  
  
      
        
          | std::any xtd::forms::application_context::tag  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
noexcept   | 
  
 
Gets an object that contains data about the control. 
- Returns
 - A std::any that contains data about the control. The default is empty. 
 
 
 
◆ tag() [2/2]
      
        
          | void xtd::forms::application_context::tag  | 
          ( | 
          std::any  | 
          tag | ) | 
           | 
        
      
 
Sets an object that contains data about the control. 
- Parameters
 - 
  
    | tag | A std::any that contains data about the control. The default is empty.  | 
  
   
 
 
◆ exit_thread()
      
        
          | void xtd::forms::application_context::exit_thread  | 
          ( | 
           | ) | 
           | 
        
      
 
Terminates the message loop of the thread. 
- Note
 - exit_thread and exit_thread_core do not actually cause the thread to terminate. These methods raise the thread_exit event to which the Application object listens. The Application object then terminates the thread. 
 
 
 
◆ exit_thread_core()
  
  
      
        
          | virtual void xtd::forms::application_context::exit_thread_core  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
protectedvirtual   | 
  
 
Terminates the message loop of the thread. 
- Note
 - exit_thread and exit_thread_core do not actually cause the thread to terminate. These methods raise the thread_exit event to which the Application object listens. The Application object then terminates the thread. 
 
 
 
◆ on_main_form_closed()
  
  
      
        
          | virtual void xtd::forms::application_context::on_main_form_closed  | 
          ( | 
          object &  | 
          sender,  | 
         
        
           | 
           | 
          const event_args &  | 
          e  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
protectedvirtual   | 
  
 
Calls ExitThreadCore(), which raises the ThreadExit event. 
- Parameters
 - 
  
    | sender | The object that raised the event.  | 
    | e | The event_args that contains the event data.  | 
  
   
 
 
◆ thread_exit
Occurs when the message loop of the thread should be terminated, by calling exit_thread(). 
 
 
The documentation for this class was generated from the following file: