Ignore:
Timestamp:
06/28/16 17:03:36 (6 years ago)
Author:
thasling
Message:

#2615:
implemented lock for timers, because if elapsed-method takes longer than the timer to elapse again, the method is called by another thread conccurently

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r13937 r13943  
    1515
    1616    private Timer timer = null; //sends heartbeat to contact-server
     17
     18    private Object timerLock = new Object();
    1719
    1820    private ChannelFactory<IContactService> myChannelFactory;
     
    7375        res.Add(allPeers.ElementAt(index));
    7476      }
    75       return res;
     77      return allPeers;
    7678    }
    7779
     
    9092
    9193    private void SendHeartbeatToServer(object sender, ElapsedEventArgs e) {
    92       try {
    93         heartbeatClient.UpdateHeartbeat(myself);
     94      lock (timerLock) {
     95        try {
     96          heartbeatClient.UpdateHeartbeat(myself);
     97        }
     98        catch { } //nothing to do
    9499      }
    95       catch { } //nothing to do
    96100    }
    97101
Note: See TracChangeset for help on using the changeset viewer.