麻烦大家帮忙看下下面的代码,看下为什么我的代码需要让程序休眠一下才可以获得句柄?小弟我实在不知道什么原因
 Process proc = Process.Start(@"C:\WINDOWS\system32\taskmgr.exe");
                System.Threading.Thread.Sleep(180);//为什么需要让程序休眠一下才可以获得句柄?                             
IntPtr myIntPtr = FindWindow(null, "Windows 任务管理器");      
           ShowWindow(myIntPtr, SW_RESTORE); //将窗口还原
                if (myIntPtr != IntPtr.Zero)
                {
                    //MessageBox.Show("got it !!!!!!!!");            
                    SetForegroundWindow(myIntPtr);                        
             SetWindowPos(myIntPtr, (IntPtr)(-1), 0, 0, 0, 0, 0x0040 | 0x0001);                             SetCursorPos(195, 68);          
           mouse_event(0x0002, 0, 0, 0, 0);             
        mouse_event(0x0004, 0, 0, 0, 0);                 }