void OnEndedFileReaderThread(ThreadReaderInterface tri) { Debug.Assert(!InvokeRequired); this.BeginInvoke(new VCloseThread(closeThread), tri.TheThread); --_totalThreadCount; }
void StartOfFileReaderThread(object obj) { ThreadReaderInterface tri = (ThreadReaderInterface)obj; tri.Parent.BeginInvoke(new VRDeletgate(OnStartReaderThread), tri); try { // tri.Server.WaitForConnection(); using (var fs = new FileStream(tri.Filename, FileMode.Open, FileAccess.Read)) { int buffsize = 4096 * 1024; byte[] buffer = new byte[buffsize]; int readsize = 0; do { for (; ;) { try { readsize = fs.Read(buffer, 0, buffsize); break; } catch (Exception ex) { string message = string.Format("Read Error: File='{0}', Pos='{1}', Exception='{2}'", tri.Filename, fs.Position, ex.Message); if (!AskRetry(message)) { throw ex; } } } tri.WriteToServers(buffer, 0, readsize); } while (readsize > 0); } } catch (Exception ex) { Alert(ex.Message); } tri.Parent.EndInvoke(tri.Parent.BeginInvoke(new VRDeletgate(OnEndingFileReaderThread), tri)); tri.Parent.BeginInvoke(new VRDeletgate(OnEndedFileReaderThread), tri); }
void OnEndingFileReaderThread(ThreadReaderInterface tri) { Debug.Assert(!InvokeRequired); tri.ClosePipes(); }
void OnStartReaderThread(ThreadReaderInterface tri) { Debug.Assert(!InvokeRequired); ++_totalThreadCount; }