opelhatza
opelhatza

Reputation: 242

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.

Upvotes: 0

Views: 329

Answers (2)

Konstantine
Konstantine

Reputation: 81

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.

Upvotes: 2

brandon-irl
brandon-irl

Reputation: 115

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

Upvotes: 0

Related Questions