gpt4 book ai didi

c - 从 tcl 线程在 C 中定义的多线程调用函数

转载 作者:太空宇宙 更新时间:2023-11-04 02:52:31 24 4
gpt4 key购买 nike

我正在尝试将报告的一些处理移动到与主线程不同的另一个 tcl 线程,因为当报告很长时它会停止主应用程序,我有一些我需要从中调用的 C 函数返回需要它的变量的新线程。这就是我现在正在尝试做的事情

Tcl 代码:

proc pdfthread {} \
{
set threadID [thread::create]
set result "" //"getAlarmList" is the C function the rest is the parameters
thread::send $threadID [list getAlarmList 304 {2013-10-16 15:10:26} {2013-10-16 15:13:00}] result
.sumRepTxt insert end "Count = $result\n" //.sumRepTxt is just a text widget
}

截至目前,我得到无效的命令名称“getAlarmList”

最佳答案

我想我找到了一种方法,我猜新线程不知道 C 库,所以如果我加载 C 函数所在的库,那么它会识别命令,就像这样:

proc pdfthread {} \
{
set threadID [thread::create {
load ./samples.so
thread::wait}]
set result ""
thread::send $threadID [list getAlarmList 304 {2013-10-16 15:10:26} {2013-10-16 15:13:00}] result
.sumRepTxt insert end "Count = $result\n"

关于c - 从 tcl 线程在 C 中定义的多线程调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20644036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com