void UploadThread() { while (!_closed) { if (!_uploadSignal.WaitOne() || _uploadInfo == null) { continue; } UploadInfo info = _uploadInfo; try { _client.Upload(info.Path, info.Buffer, info.Offset, info.Count); _entry.AddSegment(info.ID, info.NewFileSize); } catch (Exception e) { _uploadException = e; return; } finally { _uploadInfo = null; _uploadDoneSignal.Set(); } } }