苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 3654|回复: 5

[其他] winform 窗体跳转问题

[复制链接]
发表于 2013-12-23 09:03:24 | 显示全部楼层 |阅读模式
主界面左侧为导航栏。
如:
普通窗体            
播放视频窗体                 
普通窗体            右侧为显示界面信息我是用panel去承载窗体的,设置窗体的toplevel为false,然后panel.controls.add(Form)就实现了
播放视频窗体            
普通窗体  
下面说下窗体:
窗体有两种
1.普通窗体,就是增删改查的一些简单窗体。
2.播放视频文件窗体(通过线程来播放视频文件目前通过emgu来实现的)
问题:
普通窗体之间切换是没有问题
先说说播放视频窗体中的一些关键东西
1.线程(5个)用于播放视频文件,每个线程去播放一个文件。
2.有个业务处理的线程。
3.当窗体关闭时释放资源如线程释放等。
4.播放视频窗体只有一个。每次切换都是先关闭上次打开的窗体,然后new新窗体。再放入panel中。
说说出现的问题吧:
当播放视频窗体与普通窗体切换几次后。出现假死win7不会出现未响应状态怀疑为线程等待。
求解决次问题
[img]file:///C:\Users\Administrator\Documents\Tencent Files\389063296\Image\[NQ}5D56`LT[GNK$NS_T]F2.jpg[/img]


主界面

主界面


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-12-23 09:06:42 | 显示全部楼层
咋写的这部分代码看看
 楼主| 发表于 2013-12-23 09:07:26 | 显示全部楼层
private List<Type> _formsList = new List<Type>();

        private void LoadForm()
        {
            _formsList.Clear();
            _formsList.Add(typeof(ImmigrationAlermInfoShow));
            _formsList.Add(typeof(ImmigrationManage));
            _formsList.Add(typeof(IndustryPointAlermInfoShow));
            _formsList.Add(typeof(IndustryPointManage));
            _formsList.Add(typeof(PublicPlacesAlermInfoShow));
            _formsList.Add(typeof(PublicPlacesManage));
            _formsList.Add(typeof(TrafficBayonetAlermInfoShow));
            _formsList.Add(typeof(TrafficBayonetManage));
            _formsList.Add(typeof(SkynetAlermInfoShow));
            _formsList.Add(typeof(SkynetManage));
            _formsList.Add(typeof(CommandCenterAlermInfoShow));
            _formsList.Add(typeof(CommandCenterManage));
            _formsList.Add(typeof(RealTimeVideo));
            _formsList.Add(typeof(RealTimeTrack));
        }

        private void OpenForm(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException();
            }

            for (int i = 0; i < _formsList.Count; i++)
            {
                if (_formsList[i] != null && type.Equals(_formsList[i]))
                {
                    if (_form != null)
                    {
                        _form.Close();
                        _form.Disposed += (sender, e) =>
                        {
                            _form = Activator.CreateInstance(_formsList[i]) as Form;
                            _form.TopLevel = false;
                            _form.Show();
                            panel1.Controls.Clear();
                            panel1.Controls.Add(_form);
                        };
                        _form.Dispose();
                    }
                    else
                    {
                        _form = Activator.CreateInstance(_formsList[i]) as Form;
                        _form.TopLevel = false;
                        _form.Show();
                        panel1.Controls.Clear();
                        panel1.Controls.Add(_form);
                    }
                }
            }
            GC.Collect();
        }
这是关闭窗体的代码
 楼主| 发表于 2013-12-23 09:09:07 | 显示全部楼层
if (_form != null)
            {
                _form.Close();
            }
            faceDetetiveImageBox1.Stop();
            faceDetetiveImageBox1.Dispose();
            if (_cameraCapture1 != null)
            {
                _cameraCapture1.OnReceivedImage -= OnReceivedImage1;
                _cameraCapture1.Suspend();
                _cameraCapture1.Dispose();
            }
            if (_cameraCapture2 != null)
            {
                _cameraCapture2.OnReceivedImage -= OnReceivedImage2;
                _cameraCapture2.Suspend();
                _cameraCapture2.Dispose();
            }
            if (_cameraCapture3 != null)
            {
                _cameraCapture3.OnReceivedImage -= OnReceivedImage3;
                _cameraCapture3.Suspend();
                _cameraCapture3.Dispose();
            }
            if (_cameraCapture4 != null)
            {
                _cameraCapture4.OnReceivedImage -= OnReceivedImage4;
                _cameraCapture4.Suspend();
                _cameraCapture4.Dispose();
            }
            if (_cameraCapture5 != null)
            {
                _cameraCapture5.OnReceivedImage -= OnReceivedImage5;
                _cameraCapture5.Suspend();
                _cameraCapture5.Dispose();
            }
            GC.Collect();
_cameraCpature1-5为线程负责播放视频文件。
这是在窗体关闭之前(FormClosing)执行方法
 楼主| 发表于 2013-12-23 09:09:19 | 显示全部楼层
FormClosing
发表于 2013-12-23 11:50:54 | 显示全部楼层
代码这么复杂啊,呵呵,我还以为就一点呢,我估计是报异常了,你把整个方法使用一个Try然后输出下看看是那报的错
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2025-4-20 12:41

© 2014-2021

快速回复 返回顶部 返回列表