Kamyar
Kamyar

Reputation: 18797

Performing operation in a timely manner

What is the best architecture to perform custom operations (application-level) at an interval?

Is there any specific design pattern which is considered best practice for this kind of work?

Upvotes: 1

Views: 107

Answers (2)

Tigran
Tigran

Reputation: 62276

One of the serious problem with (1) solution is that if PC is restarted, switchedoff/switchedon after a couple of days is that you need restart your app.

    void InstallMeOnStartUp()
    {
        try
        {
            Microsoft.Win32.RegistryKey key =   Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
            Assembly curAssembly = Assembly.GetExecutingAssembly();
            key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
        }
        catch (Exception ex)
        {
            //
        }
    }

Install on startup run. Using this combination can add kind of more "reliability" to your app + easier debugging then service + easier setup then service == easier maintanance then service.

Regards.

Upvotes: 1

Yuriy Faktorovich
Yuriy Faktorovich

Reputation: 68707

Create a Console Application and use Windows Task Scheduler.

Upvotes: 2

Related Questions