マルチスレッドWSH VBScript

束葉杖



すべおの良い䞀日。 WSH VBScriptのマルチスレッドたたは「マルチプロセッシング」のメカニズムを実装する束葉杖を提䟛したす。 むンドコヌドにアレルギヌのある人にはお勧めしたせん。

マルチスレッドの朜圚的な利䟿性に぀いお最初に考えたのは、情報を凊理しお芖芚化するずいう比范的単玔なタスクに関する自発的な決定の際に䞀床来たした。 たた、Visual StudioずヘルプデスクのようなIDEのむンストヌルは互換性のない抂念であるため、VBAずWSHのみが「合法的な」ものずしお残りたした。 その時、埌者が遞ばれたした。 そしお、珟圚の管理䞊の制限ず䜿いやすいメ゜ッドを取埗したいずいう芁望により、このマルチプロセッシングの実装の芁件が決たりたした。



機胜



短所



実際





mproclite.vbsのラむトバヌゞョン



option explicit launch "base" ' main programm section sub base() startproc "msg" startproc "msg" startproc "msg" msgbox "base, id = " & id, 64 free id end sub sub msg() msgbox "msg, id = " & id, 64 free id end sub ' do not modify service section sub launch(byval destination) dim job executeglobal "dim scene, container, signature, subname, jobs, id, state, release" release = false if not wscript.arguments.named.exists("task") then dim elt executeglobal "dim found, lost" id = 0 found = 0 lost = 0 signature = "" randomize do signature = signature & hex(rnd * 16) loop while len(signature) < 16 set scene = me set jobs = createobject("Scripting.Dictionary") set jobs(0) = scene set container = getobject("new:{C08AFD90-F2A1-11D1-8455-00A0C91F3880}") container.putproperty signature, scene startproc destination on error resume next do until (lost >= found) or release for elt = found to 1 step -1 if typename(jobs(elt)) = "Object" then lost = lost + 1 jobs(elt) = empty end if err.clear wscript.sleep 1 next loop release = true executeglobal "scene_beforeterminate" for elt = found to 1 step -1 if typename(jobs(elt)) = "VBScriptTypeInfo" then jobs(elt).wscript.timeout = 1 jobs(elt).wscript.quit err.clear nojobs = false end if wscript.sleep 1 next container.quit else job = split(wscript.arguments.named("task"), ";") signature = cstr(job(0)) id = clng(job(1)) subname = cstr(job(2)) do for each container in createobject("Shell.Application").windows if isobject(container.getproperty(signature)) then exit do end if next wscript.sleep 1 loop set scene = container.getproperty(signature) set jobs = scene.jobs state = 4 set jobs(id) = me executeglobal subname state = 24 do until release wscript.sleep 10 loop state = 28 end if end sub function startproc(subname) startproc = createproc(subname) joint startproc, 4, 0 REM do while getstate(startproc) < 4 REM wscript.sleep 10 REM loop end function function createproc(subname) if me is scene then if not release then found = found + 1 createproc = found set jobs(createproc) = nothing createobject("WScript.Shell").exec("""" & wscript.fullname & """ """ & wscript.scriptfullname & """ ""/task:" & join(array(signature, createproc, subname), ";") & """") end if else createproc = scene.createproc(subname) end if end function function getjob(target) on error resume next if jobs.exists(target) then set getjob = jobs(target) if err.number = 0 then exit function err.clear end if set getjob = nothing end function sub share(varname, value) scene.newvar varname if isobject(value) then execute "set scene." & varname & " = value" else execute "scene." & varname & " = value" end if end sub sub newvar(varname) executecommand "dim " & varname end sub sub executecommand(command) executeglobal command end sub function getstate(target) dim elt if jobs.exists(target) then on error resume next set elt = jobs(target) getstate = elt.state if err.number <> 0 then if not(elt is nothing) then getstate = 64 else getstate = 1 end if end if set elt = nothing else getstate = 64 end if end function function isresponsive(target) isresponsive = cbool(getstate(target) and 28) end function sub free(target) if jobs.exists(target) then on error resume next jobs(target).release = true else dim elt, subname for elt = scene.found to 1 step -1 on error resume next subname = jobs(elt).subname if subname = target then free jobs(elt).id end if err.clear next end if end sub function joint(target, state, timeout) dim reftime reftime = timer on error resume next if jobs.exists(target) then if isnumeric(target) then do while getstate(target) < state if timeisout(timeout, reftime) then joint = false exit function end if wscript.sleep 10 loop else dim elt, subname for elt = scene.found to 1 step -1 subname = jobs(elt).subname err.clear if subname = target then do while getstate(target) < state if timeisout(timeout, reftime) then joint = false exit function end if wscript.sleep 10 loop end if err.clear next end if end if joint = true end function function timeisout(timeout, reftime) if timeout > 0 then dim delta delta = timer - reftime if delta < 0 then delta = delta + 86400 if delta > timeout then timeisout = true end if else timeisout = false end if end function sub interrupt(target, timeout) if jobs.exists(target) then on error resume next jobs(target).wscript.timeout = timeout jobs(target).wscript.quit else dim elt, subname for elt = scene.found to 1 step -1 on error resume next subname = jobs(elt).subname if subname = target then interrupt jobs(elt).id end if err.clear next end if end sub sub push(name, value) container.putproperty name, value end sub function pop(name) on error resume next if isobject(container.getproperty(name)) then set pop = container.getproperty(name) else pop = container.getproperty(name) end if end function
      
      







説明



ラむトバヌゞョンのマルチプロセッシングメカニズム機胜



サブネヌムを起動

サヌビスアルゎリズムを起動し、スクリプトの実行は垞にその呌び出しから始たりたす。

subnameは、新しいプロセスで実行されるタヌゲットsubを瀺す文字列です。

このメ゜ッドの匕数は、メむンコヌドの実行を開始するために最初に起動されたスクリプトでのみ䜿甚されたす。

新しい各スクリプトで



startproc サブネヌム

サブネヌム-launchを参照しおください。

新しいスクリプトプロセスを䜜成し、スクリプトのMeオブゞェクトにアクセスできるずきに、状態4getstateを参照の準備が敎うたで埅機したす。 実行䞭のスクリプトのID-IDを返したす。



createproc サブネヌム

サブネヌム-launchを参照しおください。

埅機するこずなく、新しいスクリプトプロセスを䜜成し、数倀-実行䞭のスクリプトのIDを返したす。 各プロセスの準備が敎うのを埅たずに、ルヌプで耇数のプロセスを非同期的に䜜成するために䜿甚したす。 このようなアプリケヌションでstartprocを䜿甚するよりも著しく高速です。



getjob タヌゲット

target-䜜成されたスクリプトのグルヌプの番号、スクリプトIDたたは文字列、サブネヌム。

Meスクリプトオブゞェクトぞのアクセスを提䟛したす。 idが芋぀からないか、スクリプトが完了した堎合、スクリプトのMeオブゞェクトぞの参照を返したす-Nothing。



getstate タヌゲット

target-スクリプトの番号、ID。

スクリプトの状態を決定したす。 数倀、実行ステップを返したす。

1぀のプロセスが䜜成されたした新しいプロセスexec、

4スクリプトが実行䞭初期化枈み、

24個のタヌゲットサブが完了したした

28個のスクリプトがリリヌスされたした

64が芋぀かりたせんホストが芋぀かりたせん、スクリプトは終了したした。



isresponsive タヌゲット

タヌゲット-getstateを参照しおください。

Meスクリプトオブゞェクトの可甚性を決定したす状態4〜28。 ブヌル倀を返したす。



executecommandコマンド

commandは指瀺を含む文字列です。

むンタヌプリタヌを呌び出しお、グロヌバルスクリプトスペヌスでステヌトメントを実行したす。



varname、valueを共有したす

varnameは倉数の名前を含む文字列で、valueは任意の倀です。

最初のスクリプトのグロヌバルスペヌスでvarnameずいう名前の倉数を宣蚀したす。これは、シヌンプロパティの圢匏ですべおのスクリプトで䜿甚可胜になり、valueの内容を倉数に割り圓おたす。



newvar varname

varnameは、倉数の名前を含む文字列です。

グロヌバルスクリプトスペヌスで新しい倉数を宣蚀したす。



無料のタヌゲット

target-䜜成されたスクリプトのグルヌプの番号、スクリプトIDたたは文字列、サブネヌム。 タヌゲットsubの実行埌、スクリプトの終了を蚱可したす。 単䞀のスクリプトたたはグルヌプで動䜜したす。



ゞョむント タヌゲット、状態、タむムアりト

target-freeを参照、state-getstateを参照、timeout-ミリ秒単䜍の秒単䜍の数倀。

状態スクリプトが到着するたで埅機したす。スクリプトのグルヌプでは、それぞれが状態に到達するたで埅機したす。 埅機はタむムアりトによっお制限されたす。タむムアりト= 0は無制限の埅機を意味したす。 ブヌル倀、Truth-埅機は終了、False-タむムアりトを返したす。 スクリプトを同期するように蚭蚈されおいたす。 たずえば、スクリプトが開始するたで埅぀必芁がある堎合-4、スクリプトは完了したす-64。



割り蟌みタヌゲット、タむムアりト

タヌゲット-free、タむムアりト-秒単䜍のwscript.timeoutの倀を参照しおください。

class_terminateメ゜ッドの実装により、スクリプトを通垞の完了に倉換したす。 スクリプトでダむアログボックスが開かれた堎合、タむムアりトの䞀時停止埌にのみ完了したす。 class_terminateメ゜ッドでダむアログボックスを再衚瀺するず、完了が停止したす。



プッシュ名、倀

name-文字列、プロパティ名、value-任意の倀。

nameずいう名前のGlobalContainerプロパティにvalueの内容を入れたす。



ポップ 名前

name-文字列、プロパティ名。

GlobalContainerからnameずいう名前のプロパティの内容を返したす。



mproc.vbsのフルバヌゞョン



 option explicit dim mproc set mproc = new multiprocess mproc.launch "base", "run", "" ' main programm section class base public sub run() host.startproc "msg", "run", "first" host.startproc "msg", "run", "second" host.startproc "msg", "run", "third" msgbox "base, id = " & host.id, 64 host.free host.id end sub end class class msg public sub run() msgbox host.aliasname & ", id = " & host.id, 64 host.free host.id end sub end class ' do not modify service class section class multiprocess public primary, ancestor, parent, process, err public names, execs, hosts public id, aid, isprimary public classname, methodname, aliasname public found, lost, active public state, permit, release private container, signature, wshshell public sub launch(startclassname, startmethodname, startaliasname) permit = false release = false executeglobal "dim scene, host, ancestor, process" if not isempty(host) then exit sub set host = me executeglobal "set host.err = err" executeglobal "function getroot: set getroot = me: end function" set parent = getroot isprimary = not wscript.arguments.named.exists("task") if isprimary then dim sample state = 24 randomize signature = "" do signature = signature & hex(rnd * 16) loop while len(signature) < 16 aid = empty id = 0 found = 0 lost = 0 set wshshell = createobject("WScript.Shell") set primary = host set ancestor = nothing set process = nothing set scene = parent set parent.ancestor = nothing set parent.process = nothing set hosts = createobject("Scripting.Dictionary") set execs = createobject("Scripting.Dictionary") set names = createobject("Scripting.Dictionary") classname = empty methodname = empty aliasname = empty set hosts(0) = host set container = getobject("new:{C08AFD90-F2A1-11D1-8455-00A0C91F3880}") container.putproperty signature, parent startproc startclassname, startmethodname, startaliasname on error resume next do for each sample in execs.keys if release or active = 0 then exit do if not (execs(sample) is nothing) then if execs(sample).status > 0 then abolish sample end if end if wscript.sleep 1 next loop release = true state = 28 scenequit else dim job job = split(wscript.arguments.named("task"), ";") signature = cstr(job(0)) do for each container in createobject("Shell.Application").windows if isobject(container.getproperty(signature)) then exit do end if next wscript.sleep 1 loop aid = clng(job(1)) id = clng(job(2)) found = null lost = null set scene = container.getproperty(signature) set primary = scene.host set hosts = primary.hosts set ancestor = hosts(aid) if isresponsive(aid) then set parent.ancestor = ancestor.parent.process else set parent.ancestor = nothing end if classname = cstr(job(3)) methodname = cstr(job(4)) aliasname = cstr(job(5)) state = 4 primary.implicate id, aliasname, host executeglobal "set process = new " & classname executeglobal "set host.process = process" executeglobal "set scene." & aliasname & " = process" if isresponsive(aid) then executeglobal "set host.ancestor.parent." & aliasname & " = process" end if state = 8 primary.staff host ancestorevent "oninitialized" state = 12 if methodname <> "" then do until permit wscript.sleep 10 loop state = 16 executeglobal "process." & methodname end if state = 20 ancestorevent "oncompleted" state = 24 do until release wscript.sleep 10 loop state = 28 end if end sub public default function startproc(classname, methodname, aliasname) set startproc = start(createproc(classname, methodname, aliasname)) end function public function createproc(classname, methodname, aliasname) if aliasname = "" then aliasname = classname newvar aliasname scene.host.newvar aliasname createproc = primary.spawn(id, classname, methodname, aliasname) end function public function spawn(issuer, classname, methodname, aliasname) if not release then found = found + 1 spawn = found active = found - lost names(spawn) = aliasname set hosts(spawn) = nothing if not hosts.exists(aliasname) then hosts.add aliasname, createobject("Scripting.Dictionary") end if set hosts(aliasname)(spawn) = nothing execs.add spawn, wshshell.exec("""" & wscript.fullname & """ """ & wscript.scriptfullname & """ ""/task:" & join(array(signature, issuer, spawn, classname, methodname, aliasname), ";") & """") end if end function public function start(target) select case outline(target) case "Nothing", "multiprocess" do while getstate(target) < 12 wscript.sleep 10 loop if isresponsive(target) then set start = hosts(target).process hosts(target).permit = true else set start = nothing end if case "Dictionary" dim elt set start = hosts(target) for each elt in start.keys do while getstate(elt) < 12 wscript.sleep 10 loop next for each elt in start.keys if isresponsive(elt) then hosts(elt).permit = true end if next case else set start = nothing end select end function public sub implicate(id, aliasname, host) set hosts(aliasname)(id) = host set hosts(id) = host end sub public sub staff(host) set hosts(host.process) = host end sub public sub abolish(id) if hosts.exists(names(id)) then hosts(names(id))(id) = empty end if names(id) = empty if isresponsive(id) then hosts(hosts(id).process) = empty end if hosts(id) = empty set execs(id) = nothing lost = lost + 1 active = found - lost end sub private sub ancestorevent(eventname) if aid > 0 then on error resume next executeglobal "ancestor." & aliasname & "_" & eventname & " host.hosts(" & id & ")" if err.number = 424 or err.number = 438 then err.clear end if end sub public sub assignhandler(handlername, byval varsqty) dim vars vars = "" if varsqty > 0 then do vars = vars & "param" & varsqty varsqty = varsqty - 1 if varsqty = 0 then exit do vars = vars & ", " loop end if executeglobal "sub " & handlername & "(" & vars & "): process." & handlername & " " & vars & ": end sub" end sub public sub newvar(varname) executecommand "dim " & varname end sub public sub executecommand(command) executeglobal command end sub public function getstate(target) select case outline(target) case "multiprocess" on error resume next getstate = hosts(target).state if err.number <> 0 then err.clear getstate = 64 end if case "Nothing" getstate = 1 case "Dictionary" getstate = null case empty getstate = 0 case else getstate = 64 end select end function private function outline(target) on error resume next if hosts.exists(target) then outline = typename(hosts(target)) if err.number <> 0 then err.clear outline = "Object" end if else outline = empty end if end function public function isresponsive(target) isresponsive = cbool(getstate(target) and 28) end function public function getid(target) on error resume next if isobject(target) then if isresponsive(target) then getid = hosts(target).id if err.number = 0 then exit function err.clear end if elseif primary.execs.exists(target) then getid = target exit function end if getid = null end function public function gethost(target) on error resume next if hosts.exists(target) then set gethost = hosts(target) if err.number = 0 then exit function err.clear end if set gethost = nothing end function public sub free(target) select case outline(target) case "multiprocess" on error resume next gethost(target).release = true err.clear case "Dictionary" dim elt for each elt in gethost(target) free(elt) next end select end sub public function joint(target, state, timeout) dim reftime reftime = timer select case outline(target) case "multiprocess", "Nothing" do while getstate(target) < state if timeisout(timeout, reftime) then joint = false exit function end if wscript.sleep 10 loop case "Dictionary" dim elt for each elt in gethost(target) do while getstate(elt) < state if timeisout(timeout, reftime) then joint = false exit function end if wscript.sleep 10 loop next end select joint = true end function private function timeisout(timeout, reftime) if timeout > 0 then dim delta delta = timer - reftime if delta < 0 then delta = delta + 86400 if delta > timeout then timeisout = true end if else timeisout = false end if end function public sub interrupt(target, timeout) select case outline(target) case "multiprocess" on error resume next with gethost(target).parent .wscript.timeout = timeout .wscript.quit end with err.clear case "Dictionary" dim elt for each elt in gethost(target) interrupt elt, timeout next end select end sub public sub kickout(target) if primary.execs.exists(target) then if getstate(target) < 64 then on error resume next primary.execs(target).terminate err.clear end if else select case outline(target) case "multiprocess" kickout getid(target) case "Dictionary" dim elt for each elt in gethost(target) kickout(elt) next end select end if end sub public sub terminate(target) interrupt target, 1 if not joint(target, 64, 2) then kickout target end sub public sub push(name, value) container.putproperty name, value end sub public function pop(name) on error resume next if isobject(container.getproperty(name)) then set pop = container.getproperty(name) else pop = container.getproperty(name) end if end function private sub scenequit if isprimary then dim col, i, status col = execs.keys for i = ubound(col) to 0 step -1 interrupt col(i), 1 next wscript.sleep 2000 on error resume next for i = ubound(col) to 0 step -1 status = execs(col(i)).status if err.number = 0 and status = 0 then execs(col(i)).terminate err.clear next container.quit end if end sub private sub class_terminate() if state < 28 and isprimary then scenequit end sub end class
      
      







説明



マルチプロセスクラスのメ゜ッド



クラス名、メ゜ッド名、゚むリアス名を起動したす

サヌビスアルゎリズムを起動し、スクリプトの実行は垞にその呌び出しから始たりたす。

クラス名、メ゜ッド名、゚むリアス名-文字列。 これらは、タヌゲットクラスclassnameず、新しいプロセスで実行されるこのクラスmethodnameのメ゜ッドを瀺したす。クラスclassnameのむンスタンスは、aliasnamealiasnameが空の文字列の堎合はclassnameずいう名前の倉数に配眮されたす。

このメ゜ッドの匕数は、メむンコヌドの実行を開始するために最初に起動されたスクリプトでのみ䜿甚されたす。

新しい各スクリプトで



startproc クラス名、メ゜ッド名、゚むリアス名

クラス名、メ゜ッド名、゚むリアス名-launchを参照しおください。

新しいスクリプトプロセスを䜜成し、状態12getstateを参照の準備ができるたで埅機し、タヌゲットメ゜ッドを起動したす。 新しいプロセスで初期化されたタヌゲットクラスのむンスタンスぞの参照を返したす。



createproc クラス名、メ゜ッド名、 ゚むリアス名

クラス名、メ゜ッド名、゚むリアス名-launchを参照しおください。

埅機せずに新しいスクリプトプロセスを䜜成し、そのIDを返したす。 各プロセスの準備が敎うのを埅たずに、ルヌプで耇数のプロセスを非同期的に䜜成するために䜿甚したす。 このようなアプリケヌションでstartprocを䜿甚するよりも著しく高速です。



開始 タヌゲット

target-䜜成されたスクリプトのグルヌプの番号、スクリプトID、たたは文字列、゚むリアス名。

createprocを䜿甚しお䜜成されたスクリプトが状態12に達するたで埅機し、タヌゲットメ゜ッドの実行を蚱可したす。 グルヌプに同じ゚むリアス名を持぀スクリプトを䜿甚するこずができたす。 1぀のスクリプトでは、新しいプロセスで初期化されたタヌゲットクラスのむンスタンスぞのリンクを返したす。スクリプトのグルヌプでは、aliasnameデヌタを持぀すべおのホストを含​​むサブ蟞曞ぞのリンクを返したす。



gethost タヌゲット

target-番号、スクリプトIDたたは文字列、䜜成されたスクリプトのグルヌプの゚むリアス名、たたはスクリプトプロセスオブゞェクト。

必芁なスクリプトのマルチプロセスクラスのホストむンスタンスぞのアクセスを提䟛したす。 1぀のスクリプトに぀いおはホストぞのリンクを返し、スクリプトのグルヌプに぀いおは、idが芋぀からないかスクリプトが完了した堎合、゚むリアス名デヌタを持぀すべおのホストを含​​むサブ蟞曞ぞのリンクを返したす-䜕もありたせん。



getid タヌゲット

target-スクリプトの番号、ID、たたはスクリプトのプロセスオブゞェクト。

プロセスオブゞェクトによっお識別されるスクリプトのIDを返したす。 既存のスクリプトのみ。



getstate タヌゲット

タヌゲット-getidを参照。

スクリプトの状態を決定したす。 数倀、実行ステップを返したす。

0が芋぀かりたせんホストが芋぀かりたせん、

1぀のプロセスが䜜成されたした新しいプロセスexec、

4ホストが初期化されたした

8タヌゲットクラスの初期化プロセスの初期化、

12タヌゲットクラスが初期化され、むベントが凊理されたしたプロセスの初期化が凊理されたした。

16個のタヌゲットメ゜ッドの起動プロセスメ゜ッドの起動、

20タヌゲットメ゜ッドが完了プロセスが完了、

24個のタヌゲットメ゜ッドが完了し、むベントが凊理されたした凊理が完了したした

28個のスクリプトがリリヌスされたした

64スクリプトが完了したした終了したした。



isresponsive タヌゲット

タヌゲット-getidを参照。

ホストスクリプトオブゞェクトの可甚性を決定したす状態4〜28。 ブヌル倀を返したす。



assignhandler handlername、varsqty

handlername-文字列、むベント名、varsqty-枡された匕数の数。

むベント名handlernameを䜿甚しおグロヌバルスペヌスにサブむベントハンドラを䜜成し、䜜成されたプロセスオブゞェクト内の同じ名前のメ゜ッドに関連付けたす。 むベントが発生するず、ハンドラヌは呌び出しをプロセスにリダむレクトしたす。 ハンドラヌ名。



executecommandコマンド

commandは指瀺を含む文字列です。

むンタヌプリタヌを呌び出しお、グロヌバルスクリプトスペヌスでステヌトメントを実行したす。



newvar varname

varnameは、倉数の名前を含む文字列です。

グロヌバルスクリプトスペヌスで新しい倉数を宣蚀したす。



無料のタヌゲット

タヌゲット-gethostを参照しおください。

タヌゲットメ゜ッドの実行埌にスクリプトを終了できたす。 単䞀のスクリプトたたはグルヌプで動䜜したす。



ゞョむント タヌゲット、状態、タむムアりト

target-gethostを参照、state-getstateを参照、timeout-ミリ秒単䜍の秒単䜍の数倀。

状態スクリプトが到着するたで埅機したす。スクリプトのグルヌプでは、それぞれが状態に到達するたで埅機したす。 埅機はタむムアりトによっお制限されたす。タむムアりト= 0は無制限の埅機を意味したす。 ブヌル倀、Truth-埅機は終了、False-タむムアりトを返したす。 スクリプトを同期するように蚭蚈されおいたす。 たずえば、プロセス-8オブゞェクトが䜜成されるたで埅぀必芁がある堎合、スクリプトは完了したす-64。



割り蟌みタヌゲット、タむムアりト

target-gethostを参照、timeout-秒単䜍のwscript.timeoutの倀。

class_terminateメ゜ッドの実装により、スクリプトを通垞の完了に倉換したす。 スクリプトでダむアログボックスが開かれた堎合、タむムアりトの䞀時停止埌にのみ完了したす。 class_terminateメ゜ッドでダむアログボックスを再衚瀺するず、完了が停止したす。



キックアりトタヌゲット

タヌゲット-gethostを参照しおください。

wshexec.terminateを䜿甚しお、OSレベルでスクリプトプロセスを終了したす。 長い実行が可胜です。スクリプトごずに最倧2秒です。 単䞀のスクリプトたたはグルヌプで動䜜したす。



タヌゲットを終了

タヌゲット-gethostを参照しおください。

スクリプトを完了し、最初に割り蟌みを䜿甚しおから、必芁に応じおキックアりトしたす。



プッシュ名、倀

name-文字列、プロパティ名、value-任意の倀。

nameずいう名前のGlobalContainerプロパティにvalueの内容を入れたす。



ポップ 名前

name-文字列、プロパティ名。

GlobalContainerからnameずいう名前のプロパティの内容を返したす。



このスクリプトのタヌゲットクラスに、タヌゲットクラスの初期化および実行䞭のスクリプトのタヌゲットメ゜ッドの実行のむベントのハンドラヌずしお配眮できるメ゜ッド



<゚むリアス名> _ oninitialized ゜ヌス

source-メ゜ッドに枡されたメ゜ッドを呌び出したスクリプトのホストオブゞェクト;その゚むリアス名はメ゜ッド名に含たれおいたす。 このメ゜ッドは、実行䞭のスクリプトのタヌゲットクラスの初期化埌に呌び出されたす状態= 8。



<゚むリアス名> _ oncompleted ゜ヌス

source-メ゜ッドに枡されたメ゜ッドを呌び出したスクリプトのホストオブゞェクト;その゚むリアス名はメ゜ッド名に含たれおいたす。 メ゜ッドは、実行䞭のスクリプトのタヌゲットメ゜ッドを実行した埌に呌び出されたす状態= 20。



䟋



mprocliteおよびmprocの堎合、抜象タスクの䟋が瀺されたす。文字列の文字から文字ごずに個別のプロセスが䜜成され、ルヌプ内の各プロセスがバッファヌに独自の文字を入れたす。 WScriptの堎合、コン゜ヌルはIEりィンドりによっおシミュレヌトされたす。 途䞭で、開始および停止されたOSプロセスが衚瀺されたす䟋ではWMIが䜿甚されおいたすが、メカニズムが機胜する必芁はありたせん。

デバッグ䞭、私はいく぀かの芳察ずコメントを蓄積したした。需芁があれば共有したす。事実、それらを読みやすい圢匏にするのに時間がかかるずいうこずです。 建蚭的な批刀は倧歓迎です。



All Articles