如何在另一个线程的上下文中调用函数? [英] How to call a function in context of another thread?

查看:29
本文介绍了如何在另一个线程的上下文中调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得有一种方法可以做到这一点,类似于 unix 信号,但没有被广泛使用.但是不记得这个词了.不使用事件/互斥:线程只是在随机位置被中断,函数被调用,当它返回时,线程继续.

I remember there was a way to do this, something similar to unix signals, but not so widely used. But can't remember the term. No events/mutexes are used: the thread is just interrupted at random place, the function is called and when it returns, the thread continues.

推荐答案

你可以搜索 RtlRemoteCall,不过这是一个未公开的例程.Windows 中的 APC 在语义上类似于 Unix 信号,但是 APC 要求目标线程处于警报状态才能被传递,不能保证始终满足此条件

you can search RtlRemoteCall, it's an undocumented routine though. there's APC in Windows semantically similar to Unix signal, however APC requires target thread is in an alertable state to get delivered, it's not guaranteed this condition is always met

这篇关于如何在另一个线程的上下文中调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆