在vb6编程中使用线程 [英] To use thread in programming in vb6

查看:23
本文介绍了在vb6编程中使用线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编程使用不同的随机函数生成十六进制密钥并将其写入文本文件.我只有两个 cmd 按钮和显示当前时间和进程状态的状态栏.现在单击 cmd 按钮进行密钥生成,表单被锁定,所有其他活动都被暂停,即使时间暂停,直到过程结束.我什至不能在两者之间中止这个过程.如果可能的话,我想使用线程来解决这个问题.我该怎么做请建议.否则如果有任何其他方法可以解决这个问题,请提出.

I am programming to generate keys in hexadecimal using different random function and write it in the text file. I have only two cmd buttons and status bar which displays the current time and the status of the process. Now on clicking the cmd button for keygeneration the form gets locked up and all the other activity is suspended that is even the time is suspended until the process is over. i can even not abort the process in between. I want to solve this problem using the thread if possible. how do i do that please suggest. Else if there is any other method to sort out this issue please suggest.

感谢您期待宝贵的帮助

推荐答案

唯一的合法"在 VB6 中执行多线程的方法是通过 ActiveX EXE——只需在项目属性对话框中使用每个对象的线程选项.Matt Curland 有一个很好的例子,如何将标准 EXE 转换为多线程 ActiveX EXE.这样做可以让 VB6 调试器在不崩溃的情况下工作,因为在 IDE 中,所有内容都在单个线程上执行.

The only "legal" way to do multi-threading in VB6 is through ActiveX EXEs -- just use the thread per object option on the project properties dialog. Matt Curland has a good example how to convert your Standard EXE to a multi-threaded ActiveX EXE. Doing it this way allows VB6 debugger to works w/o crashes because in the IDE everything is executed on a single thread.

如果您想减少 ActiveX EXE 多线程的开销,那么您必须使用不受支持但仍然可行的进程内多线程.检查 Compact In-Process Multi-threading: A FolderWatcher with sample UI 用于安全使用 CreateThread 并在新线程上安全地初始化 VB6 运行时(再次由 Matt Curland 提供).

If you want to cut down the overhead of ActiveX EXE multi-threading then you have to use in-proc multi-threading which is not supported but still doable. Check Compact In-Process Multi-threading: A FolderWatcher with sample UI for a way to safely use CreateThread and to safely initialize VB6 run-time on the new thread (courtesy Matt Curland again).

您可能需要查看他的Advanced Visual Basic 6 一书了解更多详情.

You might want to check his Advanced Visual Basic 6 book for more details.

这篇关于在vb6编程中使用线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆