WPF 功能实现

1.UI异步

Application.Current.Dispatcher.BeginInvoke(new Action(() => StopPlayFile()));

2.计数器使用

public System.Timers.Timer m_ConnectionTimer = new System.Timers.Timer();

  m_ConnectionTimer.Elapsed += CheckConnectionFunc;

   m_ConnectionTimer.Interval = 2000;

  public void CheckConnectionFunc(object sender, System.Timers.ElapsedEventArgs e)
        {
            Application.Current.Dispatcher.BeginInvoke(new Action(() => EndAudioRec()));

        }

  private void button1_Click(object sender, RoutedEventArgs e)
        {
            m_ConnectionTimer.Start();//开始
        }
        private void EndAudioRec()
        {
            m_ConnectionTimer.Stop();//结束

        }

3.获取程序绝对路径

 AppDomain.CurrentDomain.BaseDirectory

猜你喜欢

转载自blog.csdn.net/xionglifei2014/article/details/80817317