找回密码
 加入
搜索
楼主: woeiwoei

[转贴] AU3多进程代替多线程

[复制链接]
发表于 2010-12-3 22:38:06 | 显示全部楼层
痛苦哦。。。
发表于 2010-12-3 23:25:21 | 显示全部楼层
看看你。。
发表于 2010-12-4 00:21:47 | 显示全部楼层
向“大傻”们学习
发表于 2010-12-6 09:22:12 | 显示全部楼层
不有光说的,要用融合说话
发表于 2011-1-27 08:27:46 | 显示全部楼层
呃……把以前的帖子复制一下就能赚钱了啊……
发表于 2011-2-6 02:04:21 | 显示全部楼层
不过能有个例子看下就更形象了。
发表于 2011-2-6 10:14:27 | 显示全部楼层
我来回复一下吧。真是的!
发表于 2011-2-6 14:04:06 | 显示全部楼层
#NoTrayIcon
#include "CoProc.au3"
#region 主程序区域
#include <GUIConstants.au3>
$Form1 = GUICreate("Multiple File Copy", 622, 119, 192, 125)
GUICtrlCreateLabel("Process1", 8, 8)
GUICtrlCreateLabel("Process2", 8, 48)
$Progress1 = GUICtrlCreateProgress(8, 24, 601, 17)
$Progress2 = GUICtrlCreateProgress(8, 64, 601, 17)
$Button1 = GUICtrlCreateButton("Pause", 8, 88, 81, 25)
$Button2 = GUICtrlCreateButton("Resume", 96, 88, 81, 25)
$iPidSmall = _CoProc("Small") ;开启子进程,子进程将执行Small()函数,$iPidSmall得到的是子进程的PID
$iPidBig = _CoProc("Big")
GUISetState(@SW_SHOW)

_CoProcReciver("Reciver") ;注册Reciver()函数来接收子进程传递过来的消息

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
         _ProcSuspend($iPidSmall) ;暂停$iPidSmall这个子进程
         _ProcSuspend($iPidBig)
    Case $msg = $Button2
         _ProcResume($iPidSmall) ;恢复$iPidSmall子进程
         _ProcResume($iPidBig)
    Case Else
        ;
    EndSelect
WEnd
FileDelete(@TempDir & "smalltest.tmp")
FileDelete(@TempDir & "bigtest.tmp")
Exit

Func Reciver($vParameter)
    ;$vParameter里就是子进程发来的消息
    $aParam = StringSplit($vParameter,"|")
    If $aParam[1] = "small" Then GUICtrlSetData($Progress1,$aParam[2])
    If $aParam[1] = "big" Then GUICtrlSetData($Progress2,$aParam[2])
EndFunc
#endregion  

#region Small()函数里是'Small file'子进程的所要执行的代码
Func Small()
        Local $i=1
    While $i<>1000 And ProcessExists($gi_CoProcParent)
        ;在下载时不断向父进程发送下载进度,$gi_CoProcParent是父进程的PID,这个变量是函数自己建立的)
         _CoProcSend($gi_CoProcParent,"small|" & Round($i / 1000 * 100,0))
                 ToolTip("Small="&Round($i / 1000 * 100,0), 0, 0)
        Sleep(250)
                $i+=1
    WEnd
         _CoProcSend($gi_CoProcParent,"small|100")
EndFunc
#endregion

#region 'Big file'子进程执行的代码
Func Big()
        Local $i=1
    While $i<>1000 And ProcessExists($gi_CoProcParent)
        ;在下载时不断向父进程发送下载进度,$gi_CoProcParent是父进程的PID,这个变量是函数自己建立的)
         _CoProcSend($gi_CoProcParent,"Big|" & Round($i / 1000 * 100,0))
                 ToolTip("Big="&Round($i / 1000 * 100,0), 0, 20)
        Sleep(500)
                $i+=1
    WEnd
        _CoProcSend($gi_CoProcParent,"Big|100")
EndFunc
#endregion
仿照老大的例子写的!!
发表于 2011-3-11 10:57:15 | 显示全部楼层
期待方便好用的多线程
发表于 2011-3-11 10:59:18 | 显示全部楼层
TMD购买以后发现上当了,LZ就是把以前的帖子复制过来加了个下载,居然还收钱,TMD不厚道啊

原帖http://www.autoitx.com/forum.php ... hlight=%CF%DF%B3%CC
发表于 2011-3-20 13:23:12 | 显示全部楼层
里面有什么啊
发表于 2011-3-21 07:07:23 | 显示全部楼层
AU3对于多线程是完美支持的,谁再说AU3不支持多线程我跟谁急,这是真的。
pusofalse 发表于 2010-7-5 22:58


连官方都说不支持,你居然说“完美支持”,这真那跟那呀。

---------------------------------
看它的Todo:就有下面的
Things NOT on the ToDo List里,居然第一条就是:Multi-threading ,理由是:

Multi-threading: It's too late to do this now. The changes required to AutoIt are too great. AutoIt was never intended to be multi-threaded. Writing a multi-threaded application requires an entirely different mindset when writing a program. We did not start with that mindset and trying to retrofit something as significant as multi-threading onto the existing code base is not worth the time or effort. It would be far more beneficial to re-write AutoIt and add in multi-threading that way. That, however, is not planned and is a massive undertaking.

整个链接如下:http://www.autoitscript.com/trac/autoit/wiki/AutoItNotOnToDoList
看来是没有希望了。也是开始时,始做者没有想实现这么多功能,只当autoit相当于扩大版的bat而已。
现在想实现,几乎所有的函数都得重写一下,工程量太多了。但的确多线程太重要了。当你用autoit写了太多功能时,就会发现,经常会若一个功能/界面没有退出,别的功能/界面无法调出来的。
发表于 2011-3-25 14:10:36 | 显示全部楼层
是什么东西?看不到。。。
发表于 2011-5-23 21:43:13 | 显示全部楼层
我又白花钱了
发表于 2011-5-23 22:20:26 | 显示全部楼层
今天再来拜访,真的受用了,非常的感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 16:50 , Processed in 0.092288 second(s), 18 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表