问题描述
我负责在桌面应用程序中将文档从asciidoc格式转换为HTML格式。我使用AsciidoctorJ Java-wrapper库,如下所示:
asciidoctor asciidoctor = asciidoctor.Factory.create();
Options html = OptionsBuilder.options().
backend("html").
get();
asciidoctor.convertFile(
new File("test.asciidoc"),html);
我想提供取消转换的功能,例如,当用户单击应用程序UI上的“取消”按钮时,转换应停止。为了使UI保持响应状态,我在单独的线程中运行了上述片段。
据我所知in Java thread can be stopped only in cooperative way。不推荐使用Thread.stop()
之类的方法。而且asciidoctorJ似乎没有提供取消转换的功能。因此,org.asciidoctor.asciidoctor.convertFile()
(以及其他方法)不会返回一种可用于控制转换的处理程序。只有一种方法或多或少适合:org.asciidoctor.asciidoctor.shutdown()
。
方法声明的文档:
有更好的解决方案吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)