Exemplo n.º 1
0
        void OnEndedFileReaderThread(ThreadReaderInterface tri)
        {
            Debug.Assert(!InvokeRequired);

            this.BeginInvoke(new VCloseThread(closeThread), tri.TheThread);
            --_totalThreadCount;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 void OnEndingFileReaderThread(ThreadReaderInterface tri)
 {
     Debug.Assert(!InvokeRequired);
     tri.ClosePipes();
 }
Exemplo n.º 4
0
 void OnStartReaderThread(ThreadReaderInterface tri)
 {
     Debug.Assert(!InvokeRequired);
     ++_totalThreadCount;
 }