开发者

Cross Threading between UI and Background Thread

I've written a program that allo开发者_如何学运维ws the user interface thread to access a populated array at almost any time. This array is populated by a separate background worker thread within an object.

What will happen when the user interface thread accesses this array? Will it automatically lock it down before accessing it?

I'm writing my code in managed C++/CLI.


Array is not locked automatically. If it is accessed from multiple threads, it is your responsibility to provide synchronization.

Another way is to serialize array update from a worker thread(s) through Control.BeginInvoke call - in this case array is accessed/changed only from UI thread, and synchronization is not needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜