Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net UI和后台线程之间的交叉线程_.net_C++_Multithreading_Command Line Interface_Managed C++ - Fatal编程技术网

.net UI和后台线程之间的交叉线程

.net UI和后台线程之间的交叉线程,.net,c++,multithreading,command-line-interface,managed-c++,.net,C++,Multithreading,Command Line Interface,Managed C++,我编写了一个程序,允许用户界面线程几乎在任何时候访问填充的数组。此数组由对象内的单独后台工作线程填充 当用户界面线程访问此数组时会发生什么?它会在访问它之前自动锁定它吗 我正在用托管C++/CLI编写代码 阵列未自动锁定。如果它是从多个线程访问的,那么您有责任提供同步 另一种方法是通过Control.BeginInvoke调用从工作线程序列化阵列更新-在这种情况下,阵列仅从UI线程访问/更改,不需要同步

我编写了一个程序,允许用户界面线程几乎在任何时候访问填充的数组。此数组由对象内的单独后台工作线程填充

当用户界面线程访问此数组时会发生什么?它会在访问它之前自动锁定它吗


我正在用托管C++/CLI编写代码

阵列未自动锁定。如果它是从多个线程访问的,那么您有责任提供同步

另一种方法是通过Control.BeginInvoke调用从工作线程序列化阵列更新-在这种情况下,阵列仅从UI线程访问/更改,不需要同步