Ejemplo n.º 1
0
        public static BackgroundAction StartAsync(int interval, Action action)
        {
            var a = new BackgroundAction(action)
            {
                Interval = interval
            };

            a.StartAsync();
            return(a);
        }
Ejemplo n.º 2
0
        private BackgroundAction StartBufferThread(Guid id, StreamReader reader)
        {
            var bufferSize = 8192;
            var buffer = new char[bufferSize];

            var action = new BackgroundAction(() =>
            {
                var bytesRead = reader.Read(buffer, 0, bufferSize);

                lock (_buffers)
                {
                    StringBuilder sb;

                    if (_buffers.TryGetValue(id, out sb))
                    {
                        sb.Append(new string(buffer, 0, bytesRead));
                    }
                }
            }) { Interval = 100 };

            action.StartAsync();

            return action;
        }
Ejemplo n.º 3
0
 public static BackgroundAction StartAsync(int interval, Action action)
 {
     var a = new BackgroundAction(action) { Interval = interval };
     a.StartAsync();
     return a;
 }