by tim91700 at 2012-12-11 04:43:12
Hello,by nohandle at 2012-12-11 05:33:44
I want to do this :
I have two buttons, one to start an action, one to stop it.
If I click on start, the action is ok, if I click on stop, the action is stopped.
My code :function do_start
{
$boutonLauchScan.Enabled = $false
$boutonStopScan.Enabled = $true
$GLOBAL:conditionStop = 1
while ($conditionStop -eq 1)
{
$("ok")
}
}
function do_stop
{
$boutonLaunchScan.Enabled = $true
$GLOBAL:conditionStop = 0
}
I only crash my script and not do what I want, any help ?
What is the error message on the crash?by tim91700 at 2012-12-11 05:44:52
seems like you are running one action and then intercept it when calling another function. But there is too little context and info to be sure.
In fact it’s the script editor (Power GUI) which crash.by nohandle at 2012-12-11 06:21:49
That’s it, I want to intercept and close the action lauch by another one. Maybe a thread (or something like) will be good ?
I am not sure, as I said there is too little info and context. Have you tried in console? Maybe STA mode is in your way.by tim91700 at 2012-12-11 07:05:32[System.Management.Automation.Runspaces.Runspace]::DefaultRunspace.ApartmentState -eq [Threading.ApartmentState]]
You [quote="tim91700"]That’s it, I want to intercept and close the action lauch by another one. Maybe a thread (or something like) will be good ?[/quote]
What about powershell Jobs?
Actually, it’s for a script like an IP scanner, so I can’t use it as a job.by nohandle at 2012-12-11 07:10:02
I’ll find documentation about Runspaces.
Would you mind sharing the reason why jobs can’t be used?by tim91700 at 2012-12-11 23:02:22
Because this project is for school, and I’ll execute it on Windows and not on a VMby nohandle at 2012-12-12 02:00:29
[quote="tim91700"]Because this project is for school, and I’ll execute it on Windows and not on a VM[/quote]
I dont’t think we understand each other. I don’t see any relation btween running the script in virtual machine and beckground jobs.
There is some info on the topic:
http://msdn.microsoft.com/en-us/library … 88(v=vs.85).aspx