Starts a Windows Presentation Foundation (WPF) application.
Assembly: PresentationFramework (in PresentationFramework.dll)
Run is called to start a WPF application. If you define your Application using markup, or markup and code-behind, Run will be called implicitly. However, if you define your Application using code, you will need to explicitly call Run.
When Run is called, Application attaches a new Dispatcher instance to the UI thread. Next, the Dispatcher object's Run method is called, which starts a message pump to process windows messages. Finally, the Dispatcher object calls the Application object's the OnStartup method to raise the Startup event. Consequently, the application execution model has been established by the time you handle Startup, at which point the application is considered to be running.
An application stops running when Shutdown is called; the value of the ShutdownMode property determines when Shutdown is called, and whether it happens automatically or you need to explicitly call it.
Imports Microsoft.VisualBasic Imports System Imports System.Windows Namespace VisualBasic Public Class EntryPoint ' All WPF applications should execute on a single-threaded apartment (STA) thread <STAThread()> Public Shared Sub Main() Dim app As New CustomApplication() app.Run() End Sub End Class Public Class CustomApplication Inherits Application Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs) MyBase.OnStartup(e) Dim window As New Window() window.Show() End Sub End Class End Namespace
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.