简体   繁体   中英

c# WPF how to delay autostart of an application?

My question is how can i delay the autostart on user logon in an WPF Project. Because its necessary on this application.

I tried:

void OnStartup(StartupEventArgs e)
    {
        Thread.Sleep(60000);
        base.OnStartup(e);

    }

but it seems like the OnStartup method isnt aviable. Its always an error. So there is something i dont get.

This answer might have what you're looking for:

I think what you really want to do is to subscribe to the Startup event. You can do this in your XAML file

Click here to get started with WPF

You can always just use

public App()
   {
      System.Threading.Thread.Sleep(10000)
   }

on the App.xaml.cs

Of as already mentioned you need to subscribe to the OnStartup event on xaml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM