小编ike*_*kel的帖子

带参数的Dispatch.Invoke(new Action ...)

以前我有过

Dispatcher.Invoke(new Action(() => colorManager.Update()));
Run Code Online (Sandbox Code Playgroud)

从另一个线程更新显示到WPF.由于设计,我不得不改变程序,我必须将ColorImageFrame参数传递给我的ColorStreamManager.Update()方法.

链接之后,我将我的调度程序修改为:

Dispatcher.Invoke(new Action<ColorStreamManager, ColorImageFrame>((p,v) => p.Update(v)));
Run Code Online (Sandbox Code Playgroud)

它编译得很好但根本不会运行.VS2010说"参数计数不匹配".在我的ColorStreamManager.Update()方法中,我有 RaisePropertyChanged(() => Bitmap);

有人可以指出我哪里出错了吗?

ColorStreamManager.Update()方法的签名如下:

 public void Update(ColorImageFrame frame);
Run Code Online (Sandbox Code Playgroud)

.net c# wpf multithreading

15
推荐指数
1
解决办法
4万
查看次数

按索引而不是名称引用列

背景

我有一个调查表如下

E313     B515       C515      ...   (more columns)
1122     John doe   I don't like the lesson
2211     Mary Jane  It was excellent
Run Code Online (Sandbox Code Playgroud)

调查提供者还提供了用于解码调查中的列的标签,如下 ( survey_data_map.csv):

Code    Label
E313    Unique Identifier
B515    Full name
C515    Feedback
.
.
.
(more rows)

Run Code Online (Sandbox Code Playgroud)

因此,我编写了一个小片段,将调查中的列解码为列标签。

survey_data_map <- read.csv("survey_data_map.csv")
for(i in 1:length(names(survey))) {
  
  label <- survey_data_map$Label[survey_data_map$Code == names(survey)[i]]
  if (length(label) > 0) {
    names(survey)[i] <- label  
  }
}
Run Code Online (Sandbox Code Playgroud)

问题

解码列名的列名survey_data_map.csv可能会改变。我的问题是如何重写 for 循环以使用列索引而不是使用列名CodeLabel

谢谢。

for-loop r dataframe

1
推荐指数
1
解决办法
189
查看次数

标签 统计

.net ×1

c# ×1

dataframe ×1

for-loop ×1

multithreading ×1

r ×1

wpf ×1