Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What benefit do I get from using ApplicationContext?

Tags:

c#

forms

Whats the difference between writing a program using ApplicationContext like this:

using System;
using System.Windows.Forms;

namespace Test
{
    class Test
    {
        static void Main(string[] args)
        {
            Application.Run(new Context(args));
        }
    }

    class Context : ApplicationContext
    {
        public Context(string[] args)
        {
            //the program
            Environment.Exit(1);
        }
    }
}

and standard Main?

namespace Test
    {
        class Test
        {
            static void Main(string[] args)
            {
                //the program
            }
        }
    }
like image 628
foxneSs Avatar asked Apr 29 '14 15:04

foxneSs


1 Answers

Let's say that you have common features for one set of programs and then some different features for different set of programs, but both sets have some common functionality. By using class BaseContext : ApplicationContext you can do common functionality for both and then implement specific set functionality by inheriting from BaseContext. Basically you get same benefit as from 'normal' polymorphism.

like image 76
Matas Vaitkevicius Avatar answered Oct 21 '22 10:10

Matas Vaitkevicius