in reply to Re^2: Suspend/Resume a process from Tk GUI in Windows XP
in thread Suspend/Resume a process from Tk GUI in Windows XP
Why is it a mystery for you that it is working?
Because you are effectively sharing an object between threads which was never designed to work. This is evidenced by the fact that if you try to make $ProcessObj a shared variable so that you could use it directly from other threads, you get an error message along the lines of:
Invalid value for shared scalar at ...
You've bypassed this design restriction by stringifying the object handle Win32::Process=SCALAR(0x3e820f0) into a shared variable and then string evaling it back into existence in the other thread:$ProcessObj = eval($ProcessObj_as_string).
The problem you had is that this only worked once. What my 'fix' does is avoid it being done multiple times. But the fact that it is not repeatable, means that it works by chance, rather than by design. Indeed, the design was to explicitly prevent it.
In fact the only reason it does work once for this particular object is because the object is a simple blessed scalar reference that contains a process-wide OS handle--which is just a number.
If the object contained any perlish state--that is, any perl instance variables--it wouldn't work.
Basically, you got something to work through sheer luck, but you shouldn't rely upon it for anything remotely serious.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Suspend/Resume a process from Tk GUI in Windows XP
by Dirk80 (Pilgrim) on Feb 18, 2011 at 23:48 UTC | |
by BrowserUk (Patriarch) on Feb 19, 2011 at 00:22 UTC |