Run Method
Collapse the table of content
Expand the table of content

Application.Run Method ()

 

Begins running a standard application message loop on the current thread, without a form.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Shared Sub Run

Exception Condition
InvalidOperationException

A main message loop is already running on this thread.

In a Win32-based or Windows Forms application, a message loop is a routine in code that processes user events, such as mouse clicks and keyboard strokes. Every running Windows-based application requires an active message loop, called the main message loop. When the main message loop is closed, the application exits. In Windows Forms, this loop is closed when the Exit method is called, or when the ExitThread method is called on the thread that is running the main message loop.

Most Windows Forms developers will not need to use this version of the method. You should use the Run(Form) overload to start an application with a main form, so that the application terminates when the main form is closed. For all other situations, use the Run(ApplicationContext) overload, which supports supplying an ApplicationContext object for better control over the lifetime of the application.

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft