public void ProcessResponse(ProcessResponseModel responseModel) { if (responseModel != null && !processModelQueue.IsAddingCompleted) { processModelQueue.Add(responseModel, CancellationToken.None); } }
private void ProcessQueueItems() { while (!processModelQueue.IsCompleted) { ProcessResponseModel currentresponseModel = processModelQueue.Take(); if (currentresponseModel.transcript != null) { foreach (var turn in currentresponseModel.transcript.turns) { if (!TranscriptMap.ContainsKey(turn.id)) { TranscriptMap.Add(turn.id, turn); TranscriptDataAvailable(this, new TranscriptDataEventArgs(TranscriptMap.Values.ToList())); } else { if (!TranscriptMap[turn.id].stable) { string textValueBeforeUpdate = TranscriptMap[turn.id].text; TranscriptMap[turn.id] = turn; if (string.IsNullOrEmpty(TranscriptMap[turn.id].text)) { TranscriptMap[turn.id].text = textValueBeforeUpdate; } TranscriptDataAvailable(this, new TranscriptDataEventArgs(TranscriptMap.Values.ToList())); } } } } else if (currentresponseModel.preview != null) { if (!TranscriptMap[currentresponseModel.preview.turn.id].stable) { TranscriptMap[currentresponseModel.preview.turn.id].text = currentresponseModel.preview.text; TranscriptDataAvailable(this, new TranscriptDataEventArgs(TranscriptMap.Values.ToList())); } } } }