【发布时间】:2014-12-03 13:31:57
【问题描述】:
我正在尝试更改脚本中的线程优先级,但没有成功,这是详细信息。
$thr = threads->new(\&someFunction,
$shared variable 1,
$shared variable 2,
);
我尝试过使用threads::State;
$thr->priority(2);
没有成功
所以,我认为Win32::API 必须工作
my $functionGetLastError= Win32::API->new('Kernel32',
'GetLastError',
'',
'N'
);
my $functionSetThreadPriority= Win32::API->new('Kernel32',
'SetThreadPriority',
'II', # I've tried 'PI' and 'II' as well
'N'
);
my $h = $thr->_handle();
my $success = $functionSetThreadPriority->Call( $h, 2 );
warn "Return Error #".$functionGetLastError->Call() if !$success;
再次,没有成功:(,但现在我有一个线索,脚本返回错误号
最后一个错误 6
来自MSDN site, System Error Codes (0-499),好像报错了
ERROR_INVALID_HANDLE
我做错了什么?
【问题讨论】:
标签: multithreading perl winapi thread-priority