// Called on background thread
        void ThreadedUploader()
        {
            while (true)
            {
                m_Semaphore.WaitOne();

                WorkItem item;
                lock (m_WorkItems)
                {
                    // If we got past the semaphore, and no items are left, time to clean up
                    if (m_WorkItems.Count == 0)
                    {
                        ((IDisposable)m_Semaphore).Dispose();
                        m_Client.Close();
                        return;
                    }

                    item = m_WorkItems.Dequeue();
                }

                m_Client.BeginTransaction(item.fileId);
                m_Client.Upload(FileType.Info, item.stream);

                string artifactsZip = Path.GetTempFileName();
                if (FileCompressor.Compress(item.artifactsPath, artifactsZip))
                {
                    using (var stream = new FileStream(artifactsZip, FileMode.Open, FileAccess.Read))
                        m_Client.Upload(FileType.Resource, stream);
                }
                File.Delete(artifactsZip);

                m_Client.EndTransaction();
            }
        }
Пример #2
0
        private void UploadItem(object state)
        {
            var item = (WorkItem)state;

            m_Client.BeginTransaction(item.fileId);
            m_Client.Upload(FileType.Info, item.stream);

            string artifactsZip = Path.GetTempFileName();

            if (FileCompressor.Compress(item.artifactsPath, artifactsZip))
            {
                using (var stream = new FileStream(artifactsZip, FileMode.Open, FileAccess.Read))
                    m_Client.Upload(FileType.Resource, stream);
            }
            File.Delete(artifactsZip);

            m_Client.EndTransaction();
        }