Click here to Skip to main content
15,886,055 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using windows forms .net framework When debugging a Winforms app I can no longer either minimize or move the form out of the way to view the code when a breakpoint is reached. The result is that I'm stuck with the code hidden behind an unmovable form. how do i resolve this !!! thanks in advance!!!

What I have tried:

i dont know how this is happened or changed something in the forms properties.
Posted
Updated 9-Mar-23 3:28am
Comments
Pete O'Hanlon 9-Mar-23 9:25am    
Just as a matter of interest; your form isn't set to Always On Top is it?

You can't move the form anymore because the code in the app isn't running when you hit a breakpoint.

Did you enable some option in the form, like "Always on top" or otherwise change the window parameters?
 
Share this answer
 
Comments
sahil ajmeri 2022 9-Mar-23 22:49pm    
no!!! i have not enable any option for form to remains on top..
Dave Kreskowiak 9-Mar-23 23:22pm    
Pete's suggestion below is the last thing I know of that could do this. But, just clicking in the Visual Studio window should bring it to the front.
Hmm. It works for me, which is probably not what you wanted to hear.
I put a breakpoint on a button Click event and when it hits, VS immediately comes to the fore - even if my app is maximized.
So what I am doing that is different to you?

Does ALT+TAB switch you to VS when it is "frozen"?
 
Share this answer
 
Comments
sahil ajmeri 2022 9-Mar-23 7:44am    
OriginalGriff
no ALT+TAB didn't work for me. my form is remains open and maximize even after the hitting the breakpoint
As no code is posted, we have no idea what you are doing. At a guess, if a form is unmovable, then you have a long-running operation on the UI thread. You will need to move it to a separate thread.
 
Share this answer
 
Comments
sahil ajmeri 2022 9-Mar-23 7:51am    
how do i know that which operation is running long ??? and how to move it to separate thread??
This can happen if you have a loop that takes a long time to complete, this will make your form unresponsive. Use Application.DoEvents() in the loop to make it responsive again:
Application.DoEvents Method (System.Windows.Forms) | Microsoft Learn[^]

Or as Graeme suggested: run time consuming code in a separate Thread, or even better: in a Task:
Task Class (System.Threading.Tasks) | Microsoft Learn[^]
 
Share this answer
 
Comments
sahil ajmeri 2022 9-Mar-23 7:49am    
but its only happen when i use debugger !!other wise application runs smooth.
My suspicion - open up Visual Studio settings; go to Debugging > General. I suspect that you have "Bring Visual Studio to the front when breaking in the debugger" unchecked. Make sure this is checked, and save the change. Now, rerun your code, and Visual Studio should pop to the front.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900