FINALY I found the bug !!
Well, it seams you can hack VS IDE and put it to sleep (LOL), side effects are the problems that I was experiencing, like brace matching not working anymore.
How to reproduce it:
- Create a WinForm project
- Create a Control
- Add the code bellow in the control
- Rebuild
- Open Form1 in Designer
You will notice the Thread.Sleep in action ! Now, go back to code editing, brace matching and stuff is gone. Only way to fix it is to restarting VS.
Code to reproduce bug:
public UserControl1()
{
InitializeComponent();
Application.Idle += Application_Idle;
}
void Application_Idle(object sender, EventArgs e)
{
Thread.Sleep(200); //Yeah VS IDE will sleep for 200 ms ! LOL!
}
I think VS Designer should ignore Thread.Sleep commands, shouldn't it?
Now I just check if the code is running inside VS Designer before doing my stuff by calling:
// Return if is inside VS Designer !
if (System.Reflection.Assembly.GetEntryAssembly() == null)
return;
I also tried to add this code inside Form1, it seams that VS ignores the Sleep.