public void ReadAsync(byte[] buffer, int offset, int count, Action <int> endAction) { if (_stream.DataAvailable) { Logger.Trace("Reading data synchronously"); var read = _stream.Read(buffer, offset, count); if (Logger.IsTraceEnabled) { Logger.TraceFormat("Read data synchronously {0}", read); } _daemon.Schedule( () => endAction(read)); } Logger.Trace("Reading data asynchronously"); try { _stream.BeginRead(buffer, offset, count, asyncResult => _daemon.Schedule( () => HandleEndRead(endAction, asyncResult)), null); } catch (IOException exception) { Logger.Debug("Connection Reset by Peer", exception); _daemon.Shutdown(); } }
private static void Increment(IDaemon daemon, int i) { _countArray[i]++; if (_countArray[i] != _messagesPerProcess) { daemon.Schedule(() => Increment(daemon, i)); return; } if(Interlocked.Decrement(ref _countDown) == 0) Console.WriteLine("Time: {0}", (DateTime.UtcNow - _start)); }
private static void Increment(IDaemon daemon, int i) { _countArray[i]++; if (_countArray[i] != _messagesPerProcess) { daemon.Schedule(() => Increment(daemon, i)); return; } if (Interlocked.Decrement(ref _countDown) == 0) { Console.WriteLine("Time: {0}", (DateTime.UtcNow - _start)); } }
public void Initialize(IReactor reactor, IDaemon daemon) { reactor.Daemon = daemon; daemon.Schedule(reactor.Initialize); }
public void Initialize(IReactor reactor, IDaemon daemon) { reactor.Daemon = daemon; daemon.Schedule(reactor.Initialize); }