Esempio n. 1
0
        private void DoTempFile()
        {
            Console.WriteLine("\n------------------ IN DoTempFile");
            try
            {
                //fin = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + _iFileID.ToString() + _szFileName + ".TMP", FileMode.Create, FileAccess.Write);
                _tmpFilename = Path.Combine(_appFilePath, string.Format("{0}{1}.TMP", _iFileID, _szFileName));
                fin          = new FileStream(_tmpFilename, FileMode.Create, FileAccess.Write);
                if (fin != null)
                {
                    fin.Seek(0, SeekOrigin.Begin);
                }


                while (_fileCreateInProgress)
                {
                    //Console.WriteLine("------------------ BefORE WAIT");
                    autoEventFinished.Set();     //signals the TransferCompleted function that we have made it here
                    autoEventFileGuts.WaitOne(); //wait at mutex until signal
                    //Console.WriteLine("------------------ AFTER WAIT");

                    if (fin != null)
                    {
                        while (_FileGutsList.Count > 0)
                        {
                            FileGuts fg = null;
                            lock (_FileGutsList)
                                fg = _FileGutsList.Dequeue();

                            fin.Write(fg.guts, 0, fg.iSizeOfGuts);
                        }
                    }
                }

                if (fin != null)
                {
                    fin.Close();
                    fin.Dispose();
                    fin = null;
                }
                else
                {
                    //logMessage.ToFile("Error creating file: " + _szFileName, _appFilePath, "ErrorLog.txt");
                }
            }
            catch (Exception ex)
            {
                string msg = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
                System.Diagnostics.Debug.WriteLine("ERROR in DoTempFile()\n" + msg);
            }
            finally
            {
                _stillInThread = false;
            }
        }
Esempio n. 2
0
        public void AddToFileGuts(FileGuts fg)
        {
            lock (_FileGutsList)
                _FileGutsList.Enqueue(fg);


            if (_progBar != null)
            {
                System.Windows.Forms.Application.DoEvents();

                //_progBar.SetProgressbarValue(++_fileGutCounter * 4096);
                _progBar.SetProgressbarValue(++_fileGutCounter * 1024);
            }

            if (_FileGutsList.Count > 100)
            {
                if (autoEventFileGuts != null)
                {
                    autoEventFileGuts.Set();
                }
            }

            TimeOut = 0;
        }