解决后台线程和C#/ WPF中的UI线程之间的延迟问题?

时间:2022-08-26 21:00:19

I was asked this question in an interview and still not sure what the correct answer is. The question was:

我在接受采访时被问到这个问题,但仍然不确定正确答案是什么。问题是:

"If you have a live streaming feed of data that needs to be passed from the background thread to the UI, how do you resolve latency issues between the 2 threads?"

“如果你有一个需要从后台线程传递到UI的实时流数据源,你如何解决两个线程之间的延迟问题?”

I have read about different types of locks, where multiple threads can access an object simultaneously, however I'm not sure if this is correct as a lock might not be needed. You could just put the data on the dispatcher to send it to the UI.

我已经阅读了不同类型的锁,其中多个线程可以同时访问对象,但是我不确定这是否正确,因为可能不需要锁。您可以将数据放在调度程序上以将其发送到UI。

Does anyone know the answer to this?

有谁知道答案吗?

1 个解决方案

#1


3  

I believe the right response for this question is: What latency issues?

我相信这个问题的正确答案是:什么是延迟问题?

It's impossible to answer this question without more information - how the two threads communicate, and what latency issues exist.

没有更多信息就无法回答这个问题 - 两个线程如何通信,以及存在哪些延迟问题。

#1


3  

I believe the right response for this question is: What latency issues?

我相信这个问题的正确答案是:什么是延迟问题?

It's impossible to answer this question without more information - how the two threads communicate, and what latency issues exist.

没有更多信息就无法回答这个问题 - 两个线程如何通信,以及存在哪些延迟问题。