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); }
public ObjectDatabaseClient(ObjectClient client, Func <TObject, TPrimaryKey> keySelector) { _client = client; _repository = new ObjectRepository <TObject, TPrimaryKey>("Client", keySelector); _thread = new BackgroundAction(SaveRepo) { Interval = 1000 }; _thread.StartAsync(); }