线程完成事件。 [英] Thread completion event.

查看:100
本文介绍了线程完成事件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用createthread()创建了一个线程,它返回句柄并继续运行主线程。我想知道线程完成事件,以便我可以更新我的另一个更新我的用户界面的功能。



我尝试过:



我尝试使用Createevent()和setevent(),但这种方法要求我调用wait()。我不想等。

I have created one thread using createthread() which returns me handle and keep running main thread. I would like to know that thread completion event so that i can update my another function which update my User interface.

What I have tried:

I tried using Createevent() and setevent() , but this approach asking me to call wait(). I dont want to wait.

推荐答案

如果您只想知道Windows线程是否已经终止,请使用 GetExitCodeThread函数(Windows) [ ^ ]。



如果要通知其他线程已终止此线程,则可以引发其他线程检查的事件。



但这对主(GUI)线程没有用。要通知主线程,您可以使用带有用户定义消息的 PostMessage 。消息可以通过它的句柄(例如应用程序的主窗口)发送到任何窗口。
If you only want to know if a Windows thread has terminated or not, use the GetExitCodeThread function (Windows)[^].

If you want to inform other threads that this one has terminated you can raise an event that is checked by other threads.

But this is not useful with the main (GUI) thread. To inform the main thread, you can use PostMessage with a user-defined message. The message can be send to any window by it's handle (e.g. the main window of an application).


这篇关于线程完成事件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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