Click here to Skip to main content
15,908,013 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to check selected node is parent or child ? Pin
quiteSmart13-Nov-06 1:19
quiteSmart13-Nov-06 1:19 
AnswerRe: how to check selected node is parent or child ? Pin
saqib8213-Nov-06 2:20
saqib8213-Nov-06 2:20 
QuestionUsing netscape.exe with www.yahoo.com Pin
M Riaz Bashir13-Nov-06 0:03
M Riaz Bashir13-Nov-06 0:03 
AnswerRe: Using netscape.exe with www.yahoo.com Pin
stancrm13-Nov-06 0:31
stancrm13-Nov-06 0:31 
AnswerRe: Using netscape.exe with www.yahoo.com Pin
quiteSmart13-Nov-06 0:33
quiteSmart13-Nov-06 0:33 
QuestionCompare object in C# Pin
FernandoCR13-Nov-06 0:00
FernandoCR13-Nov-06 0:00 
AnswerRe: Compare object in C# Pin
Judah Gabriel Himango13-Nov-06 11:19
sponsorJudah Gabriel Himango13-Nov-06 11:19 
QuestionRe: Compare object in C# Pin
FernandoCR13-Nov-06 22:33
FernandoCR13-Nov-06 22:33 
I want have a object with the initial services from my machine (in the code "scServicesA"), and perdidically compare that services ("scServicesA") with the actual services in the machine (in the code "scServicesB"). I want check if something to add or delete some service in my machine.

The problem is: when I compare ("if (scServicesA.Equals(scServicesB)) MessageBox.Show("IS THE SAME");"), the response is always the same "IS NOT THE SAME", even if I add or delete services.

The next is only an example to know how compare, really I want compare the services what are running ("ServiceControllerStatus.Running").

example:
public partial class Form1 : Form
    {
        ServiceController[] scServicesA;  //Initial services.
        public ServiceController scTempB;
        public ServiceController scTempA;
        public Form1()
        {            
            InitializeComponent();
            scServicesA = ServiceController.GetServices(); //Initial services.
            int cuentaA = 0; //to count the number of services in CheckListBoxA.
            clbA.Items.Clear();  
            clbB.Items.Clear(); 
            foreach (ServiceController scTempA in scServicesA)
            {
                cuentaA += 1; //Add 1 to the count of services in CheckListBoxA.
                clbA.Items.Add(scTempA.DisplayName + " (" + scTempA.ServiceName + ")" + "\r\n");  //print the services in a CheckListBox "clbA".
           }
            Timer tmr = new Timer(); //timer to periodically get services (scServicesB).
            tmr.Interval = 3000;
            tmr.Enabled = true;
            tmr.Tick += new EventHandler(tmr_tick);
            lblCuentaA.Text = cuentaA.ToString();  //Nª services in CheckListBoxA
        }
         public int cuentaB;  // To count services en CheckListBoxb
        public void tmr_tick(object sender, EventArgs e)
        {
            clbB.Items.Clear();  
            cuentaB = 0;
            ServiceController[] scServicesB;  //services get every 3 sec.
            scServicesB = ServiceController.GetServices();
            

            foreach (ServiceController scTempB in scServicesB)
            {
                clbB.Items.Add(scTempB.DisplayName + " (" + scTempB.ServiceName + ")" + "\r\n");
                cuentaB += 1;             }
            lblCuentaB.Text = cuentaB.ToString();

            if (scServicesA.Equals(scServicesB)) MessageBox.Show("Son IGUALES");  //comparison between the initial services (scServicesA) and the services get periodically (scServicesB).
            else MessageBox.Show("Son DISTINTOS");
        }
    }



Thanks,
Fernando
AnswerRe: Compare object in C# Pin
Judah Gabriel Himango14-Nov-06 5:26
sponsorJudah Gabriel Himango14-Nov-06 5:26 
NewsRe: Compare object in C# Pin
FernandoCR14-Nov-06 6:27
FernandoCR14-Nov-06 6:27 
GeneralRe: Compare object in C# Pin
Judah Gabriel Himango14-Nov-06 16:05
sponsorJudah Gabriel Himango14-Nov-06 16:05 
QuestionCD Drive monitor Pin
Eduard Keilholz12-Nov-06 23:58
Eduard Keilholz12-Nov-06 23:58 
AnswerRe: CD Drive monitor Pin
Eduard Keilholz13-Nov-06 21:44
Eduard Keilholz13-Nov-06 21:44 
QuestionResoution Compatible Project Pin
freshonlineMax12-Nov-06 22:24
freshonlineMax12-Nov-06 22:24 
AnswerRe: Resoution Compatible Project Pin
Christian Graus12-Nov-06 23:13
protectorChristian Graus12-Nov-06 23:13 
GeneralRe: Resoution Compatible Project Pin
freshonlineMax14-Nov-06 3:09
freshonlineMax14-Nov-06 3:09 
QuestionValidation - Numeric and Special Characters Pin
Deepasubramanian12-Nov-06 21:51
Deepasubramanian12-Nov-06 21:51 
AnswerRe: Validation - Numeric and Special Characters Pin
freshonlineMax12-Nov-06 22:35
freshonlineMax12-Nov-06 22:35 
AnswerRe: Validation - Numeric and Special Characters Pin
stancrm12-Nov-06 22:37
stancrm12-Nov-06 22:37 
AnswerRe: Validation - Numeric and Special Characters Pin
Christian Graus12-Nov-06 23:15
protectorChristian Graus12-Nov-06 23:15 
QuestionI need to know Crystal Report Version Pin
M Riaz Bashir12-Nov-06 21:09
M Riaz Bashir12-Nov-06 21:09 
AnswerRe: I need to know Crystal Report Version Pin
spy7712-Nov-06 21:45
spy7712-Nov-06 21:45 
GeneralRe: I need to know Crystal Report Version Pin
M Riaz Bashir12-Nov-06 22:25
M Riaz Bashir12-Nov-06 22:25 
QuestionAdd button column to ListView Pin
freshonlineMax12-Nov-06 20:03
freshonlineMax12-Nov-06 20:03 
AnswerRe: Add button column to ListView Pin
Christian Graus12-Nov-06 21:45
protectorChristian Graus12-Nov-06 21:45 

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.