What is the entry point of a WPF application?

后端 未结 4 837
长情又很酷
长情又很酷 2020-12-29 01:35

The Main method is the entry point of a C# console application. Thus, for example, if I have to start some threads or services, I will do it within the Ma

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-29 02:02

    Your main entry point is an override of OnStartup in the code-behind of App.Xaml :

    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            // here you take control
        }
    }
    

    Other points of interest might be Application.OnActivate() and the Loaded and Initialized events of your MainWindow.

    If I have to start some threads or services, where should write the code for starting them?

    Depends on what those threads/services need and want.

提交回复
热议问题