tags:

views:

50

answers:

1

I have a event ServerStateReceived here checking condition of 4 servers whether they are UP or Down going on.In this particular type of scenario server will be down on beginning but after sometime server should be Up.So all 4 servers down and ReadySent = true; is a rare case we need to look . I have a method public write() in this method I need a logic to check a condition that if the flag ReadySent = true; and all servers Are DOWN in the event ServerStateReceived,if it satisying control should go to event ServerStateReceived . if I wait here for some time the all 4 servers will be UP in that time only control will come from ServerStateReceived event to write(),,I don’t want to use sleep() method or suspend etc,,I need a logic Here through code

This is the algorithm for that this is not c# code

Write()
{
If(ReadySent = true && all servers  in the event EventHandler ServerStateReceived DOWN) 
Go to 
              public event EventHandler ServerStateReceived
              {
here checks going on 
if(all servers UP)
go to write() method
}
}

Here is the c# code where i need to implement above logic

Public write()
{
// here need the logic to move control to event ServerStateReceived if both flag ReadySent = true; and all servers DOWN stay there for some time without using sleep() once they all UP program control will come to write() method
}

private enum StateType : int
              {
                 Initial = 0,
                 Up = 1,
                 Down = 2
              }
              public event EventHandler ServerStateReceived
              {
              add
                 {
                    m_events.AddHandler(ServerStateEvent, value);
                                if (m_alarmServerUp == StateType.Up)
                    {
                       value(this,
                          new ServerStateEventArgs(ServerComponentType.AlarmServer, true));
                    }
                    else
                    {
                       value(this,
                          new ServerStateEventArgs(ServerComponentType.AlarmServer, false));
                    }
                   .
                   .
                   .

    // **like this 3 more conditions checking are going on(total 4)**
A: 
Public Write()
{
   System.Threading.Thread.Sleep(20000);
}

This will work but I need an fix for this through code on based on the algorithm or logic I have posted on the question

rahul
You say this works, so why do you need a fix? What problems are you seeing? Is the program supposed to be doing anything else while waiting for the servers to come up? And why is the method named Write() instead of WaitForServers()? (The question is difficult to understand because there is too much detail yet not enough information.)
Justin