Click here to Skip to main content
15,911,360 members
Home / Discussions / C#
   

C#

 
AnswerRe: webrequest/response live.mail.com Pin
Bernhard Hiller5-May-13 22:04
Bernhard Hiller5-May-13 22:04 
GeneralRe: webrequest/response live.mail.com Pin
Crispybc6-May-13 2:41
Crispybc6-May-13 2:41 
Questionproblem Webservice Pin
azadehrasadi5-May-13 0:12
azadehrasadi5-May-13 0:12 
AnswerRe: problem Webservice Pin
OriginalGriff5-May-13 6:08
mveOriginalGriff5-May-13 6:08 
GeneralRe: problem Webservice Pin
azadehrasadi12-May-13 2:17
azadehrasadi12-May-13 2:17 
GeneralRe: problem Webservice Pin
OriginalGriff12-May-13 2:24
mveOriginalGriff12-May-13 2:24 
GeneralRe: problem Webservice Pin
azadehrasadi12-May-13 18:31
azadehrasadi12-May-13 18:31 
QuestionWEB SERVICES Pin
sonu Ranjan4-May-13 22:16
sonu Ranjan4-May-13 22:16 
AnswerRe: WEB SERVICES Pin
Abhinav S5-May-13 20:37
Abhinav S5-May-13 20:37 
QuestionUSB device being in use Pin
Blubbo3-May-13 5:10
Blubbo3-May-13 5:10 
AnswerRe: USB device being in use Pin
Gerry Schmitz3-May-13 11:54
mveGerry Schmitz3-May-13 11:54 
GeneralRe: USB device being in use Pin
Blubbo8-May-13 8:23
Blubbo8-May-13 8:23 
GeneralRe: USB device being in use Pin
Gerry Schmitz8-May-13 11:12
mveGerry Schmitz8-May-13 11:12 
QuestionIs streamreader slow compared to other text import functions? Pin
turbosupramk33-May-13 3:42
turbosupramk33-May-13 3:42 
AnswerRe: Is streamreader slow compared to other text import functions? Pin
GuyThiebaut3-May-13 4:21
professionalGuyThiebaut3-May-13 4:21 
GeneralRe: Is streamreader slow compared to other text import functions? Pin
turbosupramk33-May-13 4:51
turbosupramk33-May-13 4:51 
AnswerRe: Is streamreader slow compared to other text import functions? Pin
Pete O'Hanlon3-May-13 4:24
mvePete O'Hanlon3-May-13 4:24 
GeneralRe: Is streamreader slow compared to other text import functions? Pin
turbosupramk33-May-13 5:13
turbosupramk33-May-13 5:13 
AnswerRe: Is streamreader slow compared to other text import functions? Pin
turbosupramk33-May-13 5:14
turbosupramk33-May-13 5:14 
GeneralRe: Is streamreader slow compared to other text import functions? Pin
DaveyM693-May-13 13:47
professionalDaveyM693-May-13 13:47 
QuestionEvent/Delegate for progress bar issue Pin
MichCl3-May-13 3:13
MichCl3-May-13 3:13 
AnswerRe: Event/Delegate for progress bar issue Pin
Eddy Vluggen3-May-13 7:21
professionalEddy Vluggen3-May-13 7:21 
GeneralRe: Event/Delegate for progress bar issue Pin
MichCl3-May-13 7:31
MichCl3-May-13 7:31 
AnswerRe: Event/Delegate for progress bar issue Pin
Eddy Vluggen3-May-13 8:29
professionalEddy Vluggen3-May-13 8:29 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplicationXXIV
{
    enum CRType { CR5, CR6 }
    public delegate void ProgressChangeHandler2(int progress, int id);
    public interface iCR
    {
        event ProgressChangeHandler2 ProgressChanged;
    }
    public class CR5 : iCR
    {
        public int SlaveIndex { get; set; }
        public event ProgressChangeHandler2 ProgressChanged;
        public CR5(int slaveIndex)
        {
            SlaveIndex = slaveIndex;
        }
        public int ProcessTagWrite() //(ref byte[] WriteDat, bool isFastProgramMode)
        {
            AttemptWrites();
            return 0;
        }
        private void AttemptWrites()
        {
            for (int i = 0; i < (10); i++)
            {
                RaiseProgressChange(i, SlaveIndex);
            }
        }
        private void RaiseProgressChange(int progress, int id)
        {
            if (ProgressChanged != null) //this is null
            {
                ProgressChanged(progress, id);  //not getting here
            }
        }
    }
    class GenericPC
    {
        public object GetPC()
        {
            var cr = Program.GetCR(CRType.CR5, 0);
            cr.ProgressChanged += new ProgressChangeHandler2(updateProgressBar);
            (cr as CR5).ProcessTagWrite();
            return cr;
        }

        private void updateProgressBar(int n, int id)
        {
            Console.WriteLine(String.Format("Progress: {0}\tid:{1}", n, id));
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var npc = new GenericPC();
            npc.GetPC();
            Console.ReadKey();
        }

        public static iCR GetCR(CRType type, int slaveIndex)
        {
            iCR cr = null;
            switch (type)
            {
                case CRType.CR5:
                    cr = new CR5(slaveIndex);
                    break;
                case CRType.CR6:
                    cr = null; //new CR6(slaveIndex);
                    break;
                default:
                    throw new ArgumentException(string.Format("A CR of type {0} cannot be found", Enum.GetName(typeof(CRType), type)));
            }
            return cr;
        }
    }
}
First things first; place the cursor on the word ProgressChangeHandler2 and press F2 (or Ctrl-R, Ctrl-R) and rename that to something without a number Big Grin | :-D
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: Event/Delegate for progress bar issue Pin
MichCl3-May-13 8:39
MichCl3-May-13 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.