1、在类里面定义一个委托事件

    public partial class Form1 : Form
    {
        public delegate void CloseVideoHandler();

        public event CloseVideoHandler CloseVideoEvent; 
    }

2、在构造函数里添加事件处理方法

  public Form1()
   {
        InitializeComponent();

        this.CloseVideoEvent += Form1_CloseVideoEvent;
   }        

3、调用事件

    if (CloseVideoEvent != null)
    {
         this.CloseVideoEvent();
    }    

4、执行事件

void Form1_CloseVideoEvent()
        {

             this.BeginInvoke(new Action(delegate
                {
                    if (vpWindows != null && vpWindows.Text.Equals("大屏播放"))
                    {
                        System.Threading.Thread.Sleep(1000);
                        vpWindows.Dispose();
                        vpWindows.Close();
                    }
                }));
        }

 

相关文章:

  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2021-04-09
相关资源
相似解决方案