phendryx / superputty

PLEASE DO NOT USE THIS FORK! IT IS QUITE OUTDATED AND DOES NOT INCLUDE UPDATES MADE BY JIM RADFORD, THE ORIGINAL DEVELOPER. USE:
https://github.com/jimradford/superputty
MIT License
185 stars 37 forks source link

Configurable additional timing #25

Open blackoise opened 13 years ago

blackoise commented 13 years ago

Some users still have problems with non attaching putty windows. It seems that the timing for the additional timing. Best thing to do at this moment is to make the amount of time configurable.

SkyBeam commented 12 years ago

Hi,

Actually I had a look at the code and did some research. It seems to me that the MainWindowHandle property sometimes returns 0 even if WaitForInputIdle() is called before. So I have inserted some code to work-around this (ctlApplicationPanel.cs, Line 1219ff):

                // Additional timing
                if(Classes.Database.GetBooleanKey("additional_timing", false))
                {
                 System.Threading.Thread.Sleep(200);
                }

                for (int i = 0; i < 500; i++)
                {
                    if (m_Process.MainWindowHandle != IntPtr.Zero)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(20);
                    m_Process.Refresh();
                }

                m_AppWin = m_Process.MainWindowHandle;

This additional for-loop basically works for me with PuTTY 0.60, 0.61 and 0.62. So this makes me believe it even works for future versions.

I have even removed the "additional timing" part as it seems not to be required any more.

Maybe this code can be reviewed and included in a future release.