internal void Enqueue(PerforceRequest request) { if (m_requestQueue.Contains(request)) throw new ArgumentException("Cannot add the same request twice"); m_requestQueue.Enqueue(request); request.Info.RegisterRequest(request); }
// A separate thread is used to execute the Perforce commands, to avoid freezing the main GUI thread. private void PerforceThreadStart() { while (m_queryRequestedEvent.WaitOne()) { // Clear the pending request queue quickly, by copying to a local array. We don't // want to lock the queue for a long time because we might block the GUI thread. PerforceRequest[] requests; lock (m_pendingRequests) { requests = new PerforceRequest[m_pendingRequests.Count]; m_pendingRequests.CopyTo(requests, 0); m_pendingRequests.Clear(); } // Execute all of the Perforce commands. foreach (PerforceRequest request in requests) { request.Execute(); } // Update the status of the paths. GetInfo(requests.Select(x => x.Uri)); } }
// A separate thread is used to execute the Perforce commands, to avoid freezing the main GUI thread. private void PerforceThreadStart() { while (m_queryRequestedEvent.WaitOne()) { // Clear the pending request queue quickly, by copying to a local array. We don't // want to lock the queue for a long time because we might block the GUI thread. PerforceRequest[] requests; lock (m_pendingRequests) { requests = new PerforceRequest[m_pendingRequests.Count]; m_pendingRequests.CopyTo(requests, 0); m_pendingRequests.Clear(); } // Execute all of the Perforce commands. foreach (PerforceRequest request in requests) request.Execute(); // Update the status of the paths. GetInfo(requests.Select(x => x.Uri)); } }
internal void UnregisterRequest(PerforceRequest request) { if (!m_requests.Contains(request)) throw new ArgumentException("Request wasn't registered with this instance"); m_requests.Remove(request); }
internal void RegisterRequest(PerforceRequest request) { if (m_requests.Contains(request)) throw new ArgumentException("Request has already been registered"); m_requests.Add(request); }