轻松穿线

发布于 2024-07-17 12:14:39 字数 89 浏览 4 评论 0原文

是否有可能从 shoooes 内部生成一个单独的线程,该线程将从命名管道中读取内容,然后将该命名管道中写入的内容打印到文本框中? 有人能举个例子来说明如何设置吗?

Is it possible from within shoooes to spawn a separate thread which will read from a named pipe and then print whatever is written in that name pipe into a text box? Would anyone have an example of how to set that up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒中人 2024-07-24 12:14:39

跨线程操作文本非常容易。 例如,尝试以下代码:

Shoes.app do
  @text = para 'Do you like ponies?'

  Thread.new do 
    sleep(4)
    @text.text += "  Of course I do!"
  end

  timer(2) {@text.text += "\nWhat a silly question."}
end

对于从命名管道读取数据,可以像任何其他文件一样对待它们,但需要注意的是,它们将阻塞,直到管道的另一端建立为止。 因此,要么使它们不阻塞,要么在打开管道之前将另一侧朝上。

It's pretty easy to manipulate text across threads. Try this code, for example:

Shoes.app do
  @text = para 'Do you like ponies?'

  Thread.new do 
    sleep(4)
    @text.text += "  Of course I do!"
  end

  timer(2) {@text.text += "\nWhat a silly question."}
end

As to reading from a named pipe, they can be treated like any other file, with the caveat that they will block until the other side of the pipe is set up. So, either make them non-blocking or just set the other side up before you open the pipe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文