How to tell if any form from my app is in foreground

…衆ロ難τιáo~ 提交于 2019-12-23 02:28:30

问题


I'd like my compact framework application to show a notification bubble ONLY when it's running "in the background". The application has several forms which may or may not be visible at any time. I'd like the notification handler (which runs on background separate thread) to be able to tell if any form from my application is currently visible on the screen.

Is there a simple way to do this that I'm missing?


回答1:


You can always monitor when the Forms and Processes change from your app and act accordingly.




回答2:


Assuming there is a way, there's a race condition here. What will you do if you determine the form is in the foreground but at the same time the user has just moved something else into the foreground? Your notification may be lost.



来源:https://stackoverflow.com/questions/433135/how-to-tell-if-any-form-from-my-app-is-in-foreground

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!