Link to home
Start Free TrialLog in
Avatar of mtakasaki
mtakasaki

asked on

C# Winforms - keeping form from getting focus when it refreshes in the background

Working on a smart client app similar to outlook. The main form has a timer that will refreshes the ui with the latest data (example. check for new messages and display them in a list). The problem is when a user opens one of these items in a new form, when the parent refreshes it pops up in front of the form the user is working on. Any easy way of making the parent stay in the background.
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mtakasaki
mtakasaki

ASKER

Found problem... the background form was publishing an event to another smartpart which was setting focus to a control.
Still not very clear what happened but I have a feeling that intrwrks's answer wre pointing to a right direction, or at least helped to find it.
The solution had nothing to do with creating a second thread...
 I finally found the problem by debugging the app and removed the code that was setting focus to the control as it was not needed. If it was needed and I had to create  a second thread to handle this then the solution provided would have been awarded points. While the feedback was greatly appreciated it didn't really help in finding the fix.
I was going to remain silent in the request to close your question, but since there was already a response that has stopped the process, I need to point out that the first sentence in my original post referenced the solution that you eventually found. Since I was unable to view any code and did not know if the focus was required, I offered a way around the problem at hand. Although the solution of removing the code causing the focus is a much better solution than the one I provided.

Regards
Jason
Thanks for responding to my question... I awarded points to both cause I could not decide on whose comments where more helpful... Thanks