📄 怎样用vb写多线程.htm
字号:
location.replace(strgoforum)}</script><br>
<table width="98%" border="0" cellspacing="1" cellpadding="4" align="center" bgcolor="#7A7138">
<tr>
<td bgcolor="#F7EBDE"><img src="http://images.gameres.com/bbs/style/snow/image/home.gif"><a href=index.asp>GameRes游戏开发论坛 </a> » <a href="showforum.asp?forumid=18">VB开发交流专区</a> » <b>怎样用VB写多线程 wxh zt</b></td>
</tr>
</table><a name="top"></a><br>
<table width="98%" border="0" cellspacing="1" cellpadding="4" align="center">
<tr>
<td bgcolor="#F7EBDE" width="40%">本主题共有<b>2</b>张帖子, 被点击<b>106</b>次</td>
<td bgcolor="#F7EBDE" align="right"><a href="newthread.asp?forumid=18"><img src="http://images.gameres.com/bbs/style/snow/image/newthread.gif" border="0" alt="发表新主题"></a><a href="newreply.asp?threadid=16426"><img src="http://images.gameres.com/bbs/style/snow/image/newreply.gif" border=0 alt="发表回复"></a><a href="newvote.asp?forumid=18"><img src="http://images.gameres.com/bbs/style/snow/image/newvote.gif" border=0 alt="发布新投票"></a></td>
</tr>
</table>
<table width="98%" border="0" cellspacing="1" cellpadding="4" bgcolor="#9D9879" align="center" style="table-layout: fixed;word-wrap: break-word">
<tr bgcolor="#F7EBDE">
<td rowspan="1" bgcolor="#F7EBDE" valign="top" width="20%" align="center"><b>wxhwhmanshan<br></b>Exp:946</b><br>
<img src="http://images.gameres.com/bbs/image/face/1.gif"><br>
高级骑士<br>
<img src="http://images.gameres.com/bbs/image/title/6.gif"></td>
<td bgcolor="#F7EBDE" valign="top" width="80%">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="26" id="table2">
<tr><td width="35%"><font color=#4A4108> 发表于: 2004-11-1 21:31:00</font></td><td><p align="right"> <a href="showuser.asp?userid=8000" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/profile.gif" border=0 alt="查看用户档案"></a> <a href="mailto:wxhanshan@163.com"><img src="http://images.gameres.com/bbs/style/snow/image/email.gif" border=0 alt="email:wxhanshan@163.com"></a> <a href="http://www.gameres.com" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/homepage.gif" border=0 alt="GameRes 游戏开发资源网"></a> <a href="showmessage.asp?action=sendmessage&username=wxhwhmanshan" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/message.gif" border=0 alt="向该用户发送论坛短信"></a> <a href="showthread.asp?postid=89874"><img src="http://images.gameres.com/bbs/style/snow/image/tree.gif" border=0 alt="以树型方式查看"></a> <a href="newfavorite.asp?threadid=16426" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/favorite.gif" border=0 alt="加入到私人收藏"></a> <a href="editpost.asp?postid=89874"><img src="http://images.gameres.com/bbs/style/snow/image/edit.gif" border=0 alt="修改帖子"></a> <a href="delpost.asp?postid=89874"><img src="http://images.gameres.com/bbs/style/snow/image/del.gif" border=0 alt="删除"></a> <a href="newreply.asp?quote=yes&postid=89874"><img src="http://images.gameres.com/bbs/style/snow/image/quote.gif" border=0 alt="引用回复"></a> </td></tr></table>
<hr noshade size="1" color="#7A7138">
<table width="100%" border="0" cellspacing="1" cellpadding="4" style="table-layout: fixed;word-wrap: break-word"><tr><td valign="top">
<img src="http://images.gameres.com/bbs/image/posticon/icon1.gif"><b>怎样用VB写多线程 wxh zt</b><br>
<br>
我们用的第一个API是CreateThread, VB的格式是:</p><p>private declare function CreateThread Lib "kernel32" (byval pThreadAttributes as any, byval dwStackSize as long, byval lpStartAddress as long, lpParameter as any, byval dwCreationFlags as long, lpThreadID as long) as long. (从vb API text viewer中拿是最真确的语法)</p><p>CreateThread的参数指出你将要创立的县城是什么样子的. CreateThread的返回值是一个县城的handle. 这里是vb的多县城初始化程序:</p><p>Public Sub Initialize(lpfnBasFunc as long) <br>dim dwStackSize as long <br>dim dwCreationFlags as long <br>dim lpThreadId as long <br>dim lpParameter as long <br>dim myNull as long <br>myNull = 0& ’create a null pointer <br>dwStackSize = 0 ’0表示用exe stack size <br>dwCreationFlags = 4 ’用4表示初始化后先不激活,让别人来激活. <br>Me.Thread = CreateThread(myNull, dwStackSize, lpfnBasFunc, myNull, dwCreationFlags, lpThreadId) <br>if Me.Thread = myNull then<br>Msgbox "create thread failed" <br>end if<br>end Sub<br>下面是两个API用来激活/暂定该线程.</p><p>private declare function ResumeThread lib "kernel32"(byval hThread as long)as longprivate declare function SuspendThread lib "kernel32"(byval hThread as long)as long</p><p>让我们来用一个变量表示当前县城的状态.<br>public ThreadStatus as boolean<br>在vb里,可用property来实现ThreadStatus的管理.</p><p><br>Public property Let Enabled(byval vNewvalue as boolean) <br>if vNewvalue = true and Me.ThreadStatus = false then<br>ResumeThread Me.Thread<br>Me.ThreadStatus = True<br>elseif Me.ThreadStatus = true then<br>SuspendThread Me.Thread <br>Me.ThreadStatus = False <br>endif<br>end Property</p><p>这个简单的类可以用New Object来引用:<br>’make new thread object<br>dim myThread as New clsThreads<br>’创建县城 Foo<br>myThread.Initialize AddressOf Foo<br>’激活县城<br>myThread.Enabled = True</p><p>执行后,你可以用PVIEW95.EXE看到你的线程.<br>你还可以提高你的线程的优先级.<br>SetThreadPriority ’设优先级GetThreadPriority ’查优先级</p><p>你把以上的程序加入timer例子,就会看到两个timer同时运行.<br>这里要提醒一下. vb5的开发环境是单县城的.如果你的程序写错,或中断后试图恢复,往往会出错,有时是GPF错.总之,用vb写多线程可以写出和VC一样快的程序.而且开发容易的多,开发速度也快得多.</p><p>抛砖引玉.希望能看到兽经,虎经,鳖经 <br><br>
<br>
</td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="right"><form method="post" action="rate.asp" target="_blank">
<tr>
<td width="70%"><font color=#DBC7B0> 注册: <b>2004-5</b> 状态: </font><font color="#8BBB9E"><b><a href='showposterip.asp?postid=89874' target=_blank><font color=#888888>Offline</font></a></b></font></td>
<td width="10%" align="right"><b><font color="#999999">1</font></b> <a href="#top">Top</a></td>
</tr></form>
</table>
</td>
</tr>
</table><table width="98%" border="0" cellspacing="1" cellpadding="4" bgcolor="#9D9879" align="center" style="table-layout: fixed;word-wrap: break-word">
<tr bgcolor="#F7EBDE">
<td rowspan="1" bgcolor="#F7EBDE" valign="top" width="20%" align="center"><b>Lv_Ximing<br></b>Exp:10</b><br>
<img src="http://images.gameres.com/bbs/image/face/9.gif"><br>
论坛新成员<br>
<img src="http://images.gameres.com/bbs/image/title/1.gif"></td>
<td bgcolor="#F7EBDE" valign="top" width="80%">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="26" id="table2">
<tr><td width="35%"><font color=#4A4108> 发表于: 2005-2-4 1:01:00</font></td><td><p align="right"> <a href="showuser.asp?userid=18101" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/profile.gif" border=0 alt="查看用户档案"></a> <a href="mailto:Lv_Ximing@hotmail.com"><img src="http://images.gameres.com/bbs/style/snow/image/email.gif" border=0 alt="email:Lv_Ximing@hotmail.com"></a> <a href="http://www.gameres.com" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/homepage.gif" border=0 alt="GameRes 游戏开发资源网"></a> <a href="showmessage.asp?action=sendmessage&username=Lv_Ximing" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/message.gif" border=0 alt="向该用户发送论坛短信"></a> <a href="showthread.asp?postid=124706"><img src="http://images.gameres.com/bbs/style/snow/image/tree.gif" border=0 alt="以树型方式查看"></a> <a href="newfavorite.asp?threadid=16426" target=_blank><img src="http://images.gameres.com/bbs/style/snow/image/favorite.gif" border=0 alt="加入到私人收藏"></a> <a href="editpost.asp?postid=124706"><img src="http://images.gameres.com/bbs/style/snow/image/edit.gif" border=0 alt="修改帖子"></a> <a href="delpost.asp?postid=124706"><img src="http://images.gameres.com/bbs/style/snow/image/del.gif" border=0 alt="删除"></a> <a href="newreply.asp?quote=yes&postid=124706"><img src="http://images.gameres.com/bbs/style/snow/image/quote.gif" border=0 alt="引用回复"></a> </td></tr></table>
<hr noshade size="1" color="#7A7138">
<table width="100%" border="0" cellspacing="1" cellpadding="4" style="table-layout: fixed;word-wrap: break-word"><tr><td valign="top">
<b>Re:怎样用VB写多线程 wxh zt</b><br>
<br>
还是用VB.Net吧,做线程太方便了。<br>
<br>
</td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="right"><form method="post" action="rate.asp" target="_blank">
<tr>
<td width="70%"><font color=#DBC7B0> 注册: <b>2005-1</b> 状态: </font><font color="#8BBB9E"><b><a href='showposterip.asp?postid=124706' target=_blank><font color=#888888>Offline</font></a></b></font></td>
<td width="10%" align="right"><b><font color="#999999">2</font></b> <a href="#top">Top</a></td>
</tr></form>
</table>
</td>
</tr>
</table><table width="98%" border="0" cellspacing="1" cellpadding="4" align="center">
<tr>
<td bgcolor="#F7EBDE" align="center"><img src="http://images.gameres.com/bbs/style/snow/image/page.gif"> 1: <b>1</b> </td>
</tr>
</table>
<br>
<table width="98%" border="0" cellspacing="1" cellpadding="4" align="center">
<tr>
<td bgcolor="#F7EBDE" width="1%"></td>
<td bgcolor="#F7EBDE" align="right">主题管理: <a href="delpost.asp?threadid=16426">删除</a> | <a href="thread.asp?action=close&threadid=16426">关闭/取消</a> | <a href="thread.asp?action=stick&threadid=16426">置顶/取消</a> | <a href="thread.asp?action=best&threadid=16426">精华/取消</a> | <a href="copythread.asp?action=move&threadid=16426">移动</a> | <a href="copythread.asp?action=copy&threadid=16426">复制</a> | <a href="editthread.asp?threadid=16426">编辑主题</a> | <a href="thread.asp?action=show_quest&threadid=16426">提问</a> | <a href="thread.asp?action=show_talk&threadid=16426">交流</a> | <a href="thread.asp?action=show_self&threadid=16426">原创</a> | <a href="thread.asp?action=show_prod&threadid=16426">作品</a> | <a href="thread.asp?action=show_industry&threadid=16426">业内</a> | <a href="thread.asp?action=show_close&threadid=16426">关闭</a> | <a href="thread.asp?action=show_clear&threadid=16426">清除</a></select></td>
</tr>
</table><SCRIPT LANGUAGE="JavaScript">
function keyup(eventobject)
{
if(event.ctrlKey && window.event.keyCode==13 && document.post.Submit.disabled==false)
{
document.post.submit();
document.post.Submit.disabled=true;
}
}
</SCRIPT>
<br><br>
<table width="98%" border="0" cellspacing="1" cellpadding="4" bgcolor="#7A7138" align="center">
<form method="post" action="newreply.asp?step=2&threadid=16426" name="post" enctype="multipart/form-data">
<tr bgcolor="#E7DBCE">
<td valign="top" align="center" colspan="2"><font color="#000000">您已经用<b>xwgang</b>登录,可以立即回复</font></td>
</tr>
<tr bgcolor="#F7EBDE">
<td bgcolor="#F7EBDE" align="right" width="20%">标题:</td>
<td bgcolor="#F7EBDE">
<input type="text" name="subject" maxlength="100" size="99" value="Re:怎样用VB写多线程 wxh zt">
</td>
</tr>
<tr bgcolor="#F7EBDE">
<td bgcolor="#F7EBDE" align="right" width="20%" valign="top"><br>
内容:</td>
<td bgcolor="#F7EBDE">
<textarea name="text" cols="100" rows="8" onkeyup="keyup()"></textarea>
</td>
</tr>
<tr bgcolor="#F7EBDE">
<td bgcolor="#F7EBDE" align="right">选项:</td>
<td bgcolor="#F7EBDE">
<input type="checkbox" name="sign" value="1" unchecked>
使用我的个性签名
<input type="checkbox" name="url" value="1" checked>
自动识别URL地址
<input type="checkbox" name="usexbcode" value="1" checked>
使用XB代码
<input type="checkbox" name="useemot" value="1" checked>
使用表情符号
</td>
</tr>
<tr bgcolor="#F7EBDE">
<td bgcolor="#F7EBDE" valign="top" colspan="2" align="center">
<input type="hidden" name="icon" value="0" >
<input type="hidden" name="attachment" value="" >
<input type="submit" name="Submit" value="提 交" OnClick="this.disabled=true;document.post.submit();"> (Ctrl+Enter快速发帖)
</td>
</tr>
</form>
</table>
<br>
<center>
<table border="1" cellpadding="0" cellspacing="0" width="98%" id="table2002" bordercolorlight="#7A7138" bordercolordark="#F7EBDE" bgcolor="#F7EBDE">
<tr>
<td>
<IFRAME id=contentFRM name=contentFRM align=center marginWidth=0 marginHeight=0 src="http://chat.gameres.com/bbs" frameBorder=0 width=100% scrolling=no height=250></IFRAME>
</td>
</tr>
</table>
<p align="center">
<font face="Arial" size="2"><br>
<a style="text-decoration: underline" href="http://www.gameres.com/about.asp">关于本站</a> | <a style="text-decoration: underline" href="http://www.gameres.com/contribute.asp">投稿指南</a> | <a style="text-decoration: underline" href="http://www.gameres.com/ad.asp">广告服务</a> |
<a style="text-decoration: underline" href="http://www.gameres.com/contact.asp">联系本站</a><br>
<br>
<IFRAME id=contentFRM name=contentFRM marginWidth=0 marginHeight=0 src=http://images.gameres.com/images/ad/ad_insert468x60.htm frameBorder=0 width=468 scrolling=no height=60></IFRAME>
<br><br>
未经书面许可,请勿转载、链接本站内容,否则非法引用所造成的后果自负;<br>
本站不对所提供的所有资讯正确性负责,若因资讯导致的任何损失本站概不负责,请自行斟酌。<br>
<a href=http://www.miibeian.gov.cn>闽ICP备05005107号</a><br>
Copyright © 2001-2005 <a href=http://gameres.com><b>GameRes游戏开发资源网</b></a> All Rights Reserved.<br>
<script src="http://data.gameres.com/ASP/Stat/mystat.asp"></script>
<br></td>
</tr>
</table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -