【问题标题】:Itcl/Tcom/Tcl/Threads: Is this thread continuously runningitcl/Tcom/Tcl/Threads:这个线程是否持续运行
【发布时间】:2017-02-20 14:07:19
【问题描述】:

在一些地方,我在一个杀死 excel 的线程中编写了 itcl 代码

method Kill_XL {} {
    thread::create {
        set rc [catch {exec taskkill /t /f /im Excel*} output]
    }
    sleep 5
}

之后,对于几个不同的愿望外壳,以下命令调用 Excel 应用程序,但我可以看到它立即在任务管理器中退出

(shh..) 2 % ::tcom::ref createobject Excel.Application
::tcom::handle0x027CE918
(shh..) 3 % ::tcom::ref createobject Excel.Application
::tcom::handle0x027CE918

对几个wish shell重复上述操作(每个都在关闭前一个wish shell后调用)。

在运行任何命令时,错误显示为:

"invalid command name ::tcom::handle0x027CE918"

但是下面的代码可以正常打开一个 Word 应用程序

(shh..) 4 % ::tcom::ref createobject Word.Application
::tcom::handle0x027CE918

等待了很长时间(15-20分钟)后,我重新启动了wish shell并能够运行(没有问题)以下代码:

(shh..) 8 % set x [::tcom::ref createobject Excel.Application]
::tcom::handle0x0272EB58
(shh..) 9 % $x Visible 1

这次杀死excel后出现不同的错误信息

(shh..) 10 % thread::create {
                set rc [catch {exec taskkill /t /f /im Excel*} output]
            }
tid00004658


(shh..) 11 % $x Visible 0
0x800706ba {The RPC server is unavailable.}

然后就是重新开始:

(shh..) 20 %  ::tcom::ref createobject Excel.Application
::tcom::handle0x0272EB58
(shh..) 21 % 
(shh..) 21 % ::tcom::handle0x0272EB58 Visible 1
invalid command name "::tcom::handle0x0272EB58"

线程杀死是否会导致问题 - 我总是睡 5 秒以确保杀死成功。

还是 tcom-Excel 的其他(已知)问题?

此外,始终提供相同的应用句柄

(shh..) 30 % foreach x  {. .} {puts [::tcom::ref createobject Excel.Application]}
::tcom::handle0x0272EB58
::tcom::handle0x0272EB58

这可能是未发布的 tcom 对象的清理问题 - 它不会在终止关联的 excel 进程时自动清理吗?

【问题讨论】:

    标签: pthreads tcl itcl


    【解决方案1】:

    这是操作系统的一些问题 - 重新映像操作系统后不会重复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多