Closed dudul closed 8 years ago
It's not possible to stop interception_wait
, it's a blocking API.
Ah, regarding 1., if interception_wait
is waiting, and you wish to just kill the thread, I'm really not sure how you would proceed, I don't recall about thread killing on Windows. But, terminating a process blocked on interception_wait
for example, is fine.
I am having the same problem and yet have to find a solution. When I use Abort() on the thread that is on InterceptionDriver.WaitWithTimeout(,10000) it still waits for the timeout. But I need to have it instantly exit.
@Knufje it may be a problem with the wrapper you're using.
This is what I have at the moment, with using tasks instead of threads again and since I don't know much about Tasks and threads I have spend hours searching, but it seems that I can't exit that wait with just my code. Is there something that I am missing? ` class InputSystem { CancellationTokenSource tokenSource = new CancellationTokenSource();
void Start()
{
Task.Run(() => interceptInput(), tokenSource.Token);
}
void Cancel()
{
tokenSource.Cancel();
}
void interceptInput()
{
bool taskAbort = false;
IntPtr context = InterceptionDriver.CreateContext();
int deviceId;
Stroke stroke = new Stroke();
try
{
while (!taskAbort)
{
while (Interceptor.InterceptionDriver.Receive(context, deviceId = InterceptionDriver.WaitWithTimeout(context, 10000), ref stroke, 1) > 0)
{
// Poll on this property if you have to do
// other cleanup before throwing.
if (tokenSource.Token.IsCancellationRequested)
{
taskAbort = true;
Form1.DebugMsg("InputSystem", "cancel active keyset.");
// Clean up here, then...
tokenSource.Token.ThrowIfCancellationRequested();
}
}
}
}
catch (OperationCanceledException e)
{
Console.WriteLine(e.ToString());
}
}
}
`
@Knufje Sorry but I can't give support for a .NET wrapper I didn't write, you should look for the .NET wrapper's help. It's an independent wrapper, with no official relation to this project.
Hi, Is there an option to stop the "interception_wait"? My situation is: My app receives a command from another application, which supposed to stop the input hooking. I thought about 2 solutions:
Please advise, Thanks