本帖最后由 dengjiejie1990 于 2012-12-13 13:24:59 编辑

解决方案 »

  1.   

    问题出在你的Joint和 Middle_Stretch的循环中,尤其是SetPixel的效率非常低,导致才Form退出时,Timer的线程还需要很长时间才能结束退出。解决办法可以设定一个Bool变量用于控制上面2个函数的退出,在Form的Closing事件中改变Bool变量使得Timer中的循环迅速退出,另外还需要先停止Timer。
      

  2.   

    要是这个就是你全部的代码的话,我想是不会造成未响应的,你先自己试试能不能将错误抓出来,知道是哪里有问题了才好解决,否则别人也只能靠猜的,不一定对 protected override void OnClosing(CancelEventArgs e)
            {
                try
                {
                    timer_Change.Enabled = false;
                    base.OnClosing(e);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
      

  3.   


     private void button_Watch_Click(object sender, EventArgs e)
            {
                WatchPic wp = new WatchPic();
                wp.MdiParent = this;
                if (Application.OpenForms["WatchPic"] == null)
                {
                    wp.Show();
                }            foreach (Form f in MdiChildren)
                {
                    if (f.Name == "WatchPic")
                    {
                        f.Activate();
                    }
                }
            }
    就是这个。。有什么问题么。。
      

  4.   


     private void button_Watch_Click(object sender, EventArgs e)
            {
                AutoPlay ap = new AutoPlay();
                ap.MdiParent = this;
                if (Application.OpenForms["AutoPlay"] == null)
                {
                    ap.Show();
                }
     
                foreach (Form f in MdiChildren)
                {
                    if (f.Name == "AutoPlay")
                    {
                        f.Activate();
                    }
                }
            }
    不是。。应该是这个。。变量名有点问题。。
      

  5.   

    在循环末端加上 Application.DoEvents();
    或者另开一个线程来实现播放管理。
      

  6.   

     /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
    winform的UI线程是单的,你的这个 Joint()Middle_Stretch()方法里面System.Threading.Thread.Sleep(1); 语句会导致主线程停止,当你将sleep时间加大的时候,任何对界面的操作都会产生大的延迟,也就是未响应了, 将这两句代码注掉         
      

  7.   


    这是Timer的事件里面的,怎么会造成UI堵塞??调试过了,解决办法我在前面说过了。就是Joint方法里面的SetPixel在图片大的时候,那循环要执行很多次,而退出的时候Timer还在跑,而且还远远因为SetPixel而没结束掉从而导致UI卡死
      

  8.   


    我加了个bool变量做标记。。但还是会未响应。。请问怎么加。。??