Click here to Skip to main content
13,007,028 members (61,224 online)
Click here to Skip to main content


58 bookmarked
Posted 10 May 2010

Dealing with Progressive Operations

, 10 May 2010
Through a clean OOP solution to deal with progressive operations, I will implicitly show you how OOP principles can work together to make a full, clean solution.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Erik.Utilities.Interfaces;

namespace Erik.Utilities.Bases
    public abstract class BaseProgressiveOperation : IProgressiveOperation
        string _title = "Proccessing";
        string _subtitle = "Please wait";

        protected int _totalSteps;
        protected int _currentStep;

        protected virtual void OnOperationStart(EventArgs e)
            if (OperationStart != null)
                OperationStart(this, e);

        protected virtual void OnOperationProgress(EventArgs e)
            if (OperationProgress != null)
                OperationProgress(this, e);

        protected virtual void OnOperationEnd(EventArgs e)
            if (OperationEnd != null)
                OperationEnd(this, e);

        #region IProgressiveOperation Members

        public event EventHandler OperationStart;

        public event EventHandler OperationProgress;

        public event EventHandler OperationEnd;

        public virtual string MainTitle
            get { return _title; }
            set { _title = value; }

        public virtual string SubTitle
            get { return _subtitle; }
            set { _subtitle = value; }

        public virtual int CurrentProgress
                int ret = 0;

                if (_totalSteps > 0)
                    ret = (100 * _currentStep) / _totalSteps;

                return ret;

        public virtual int TotalSteps
            get { return _totalSteps; }

        public virtual int CurrentStep
            get { return _currentStep; }

        public abstract void Start();


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Technical Lead
Spain Spain
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170628.1 | Last Updated 10 May 2010
Article Copyright 2010 by _Erik_
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid